• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by user-1736 (google) · Apr 13, 2010 at 09:21 PM · spawn

Death zone scripts

I am a student in the Technology Student Association (TSA) which is a way to compete and win awards for special tasks. I am making a game which involves falling blocks and i need to climb up the blocks but i cant make the character go back out of the spawn point when the death zone hits him. Please help me make or find a better death zone script.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image duck ♦♦ · Apr 13, 2010 at 09:23 PM 1
Share

I think you'll need to be clearer about what you already have, and what exactly you'd like in order for it to be "better".

avatar image spinaljack · Apr 14, 2010 at 01:05 AM 0
Share

You mean your character wont respawn after hitting a death zone? Please clarify.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by spinaljack · Apr 14, 2010 at 01:20 AM

The 3D platform game tutorial uses "fall out" zones which sounds like what you're after. You need to specify a spawn point and you need to remove the player model when it enters the death zone. Use a box collider set to trigger and enter something like this:

function OnTriggerEnter (other : Collider) {
  // destroy all game objects that enter this area
  Destroy(other.gameObject);
}

Alternatively you can hide the player character instead of removing it. Then you need to call a respawn function in your player controls script and have a new player created at your spawn point, if the player still exists you just use the translate function to move it back to the spawn point:

transform.position = respawnPosition

http://unity3d.com/support/resources/tutorials/3d-platform-game

Go to page 37

Hope that helps

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GeneralGadd · Apr 30, 2010 at 02:22 PM 0
Share

Hey that works however how would I link this to a lives script?

avatar image spinaljack · Apr 30, 2010 at 08:44 PM 0
Share

If you're destroying the player (not the best option) you'd need to instantiate another one with a control script that receives a message after the Destroy method. Like: Control.RespawnPlayer(); then you can decrease the number of lives in the RespawnPlayer method.

avatar image
0

Answer by QWERTY · Apr 14, 2010 at 03:09 AM

I am not sure if you have made an object for the death zone but here is a solution. Make a plane (if you don't have one) where the death zone is. You could add this script to the character.

private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "DEATHZONE") { dead = true; }

function LateUpdate() { if(dead) { transform.position = Vector3(0,0,0); gameObject.Find("Main Camera").transform.position = Vector3(0,0,0); dead = false; } }

Just tag your death zone whatever you want it to be called and then replace the tag I put in the script ("DEATHZONE") with the tag you made for the death zone. Change the vector 3 part of the script to the spawn point location.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Too many enemies spawned 1 Answer

Text Prefrab problem 1 Answer

Bullets don't always appear at spawn point 0 Answers

Random spawn at different locations 1 Answer

Instantiate given object on an empty game object. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges