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
1
Question by Kashaunzilla · May 16, 2011 at 04:28 AM · playerrandomrespawnplaces

Random Player Respawn Points

Ok i want it so when the game starts all players respawn from different locations. Like everyone kills each other, they respawn different places, teams they spawn near each other if the are teammates but enemies far away.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by lil_billy · May 16, 2011 at 05:17 AM

well have fun with that

there a ton of different ways to go about it i cant tell you the most efficient method since id need to play with it myself but i guess you could use dist checks or my favorite, Trigger colliders

and like if a player enters a range of a spawn point it sends a message to a command_cube (what i call my objects that are placed simply for holding world governing scripts) that message contains the players team type and what SP he got near

then when a player dies a script on the player asks the cube where to spawn and it goes from there looking at the last known coord of a teammate

after that you just use Random.Range for any randomness you want

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
avatar image
1

Answer by DaveA · May 16, 2011 at 06:17 AM

What I do is create empty game objects named 'SpawnPoint' into a parent game object called 'SpawnPoints' and place them around my scene. When I need to spawn something, I find the SpawnPoints object and then pick a random child of that ( a random spawn point), and use its transform for position and orientation. I also created a Gizmo that has an arrow to show the orientation, so I can more easily see how the player will be looking when it appears there.

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
avatar image
1

Answer by Dreamer · May 16, 2011 at 06:22 AM

Below is the script give you idea how to do it:

var respawn_x:float; var respawn_y:float;

function Respawn(friendly:boolean){ if(friendly){ respawn_x=Random.Range(-100,0); respawn_y=Random.Range(-100,100); } else{ respawn_x=Random.Range(0,100); respawn_y=Random.Range(-100,100); }

 Instantiate (player_prefab, Vector3(respawn_x, respawn_y, 0), Quaternion.identity);

}

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

Player starts instantiate at random places? 3 Answers

Making the delay actually work 1 Answer

How do I spawn a random prefab? 1 Answer

Player Respawn with Joystick 2 Answers

Player Respawn Script - Not Working 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