Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by Flipbee9 · Jun 24, 2010 at 12:55 AM · multiplerespawn

Multiple Spawn Points

So, I already got a spawn point script ready. It's simple, but that's really all I need. But now I want to have multiple spawn points. Basically, what I mean is that like, if you reach Point B, then whenever you die, you will spawn to point B. If you reach point C, whenever you die then you'll spawn to point C. Something like that. This is the script I'm using. Any reccomendations? It's a 2.5D Platformer by the way.

var spawnpoint1 : Transform; var spawnpoint2 : Transform;

function OnTriggerEnter(other : Collider) { if (other.tag == "Player") { other.transform.position = spawnpoint1.position; } }

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by qJake · Jun 24, 2010 at 04:45 AM

So here's how I would do this. Instead of just having a crapton of Transforms in your script (which is messy), you can do something like this instead.

Set up a game object, and have children game objects as the actual "spawn points". This way, you can move them around the world, and even attach an editor gizmo to them if you want. Your Hierarachy would look something like this:

Spawnpoints
|- Spawnpoint A
|- Spawnpoint B
|- Spawnpoint C
|- Spawnpoint D
|- etc...

So now, on the "Spawnpoints" game object, you can find all the "Transform" children and load them into an array, like so:

Transform[] spawnpoints = GetComponentsInChildren(typeof(Transform)) as Transform[];

And now you have an array of all of your spawnpoints (Spawnpoint A, Spawnpoint B, etc). Want to add another one? Just create a new gameobject spawnpoint, and add it to the children list along with the others. The script will find it automatically, and you don't need to add it in manually. :)

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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to use a script on multiple gameobjects, then change a variable for one of them, not the other. 3 Answers

Spawning trouble 1 Answer

Why is the particles not showing when player dies, it works fine on it's own but not when it hits a hurt object? 0 Answers

Respawn back at the old position. 1 Answer

Action executed with more than one key? 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