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 Claymore · Apr 22, 2013 at 04:26 PM · levelapplication

Need help. I want to spawn in different position after level reload!

Hi,to make script like ethis its pretty easy,but i want to know wich is the best way to make script like this : Well,when i get into trigger i die : Destroy (Player); and next action is Application.LoadLevel (Application.loadedLevel); <------ it loads the same level and i spawn in default position. All i want is : when i enter in the trigger and when level reloads,i spawn in different position,not in default,but in different (my chosen) position. Any help?

Comment
Add comment · Show 5
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 GC1983 · Apr 22, 2013 at 05:21 PM 0
Share

So you want to be able to pick a random location other than the default or you want to personally be able to choose which spawn point they go next after dying?

avatar image CaptainKirby · Apr 22, 2013 at 07:07 PM 0
Share

$$anonymous$$ake a static variable with the position you want the player to spawn at and spawn him at that?

avatar image ahaykal · Apr 22, 2013 at 07:57 PM 0
Share

In the start function change the spawn position?

avatar image GC1983 · Apr 22, 2013 at 08:08 PM 1
Share

This is not an answer, its a question that leads to no resolution. Please use the comments to understand their problem better. Thanks!

avatar image Glister · Apr 22, 2013 at 08:53 PM 0
Share

You would create your new spawn point and place it in the level. You would create a variable something like var hasSpawned = false; and when you spawn the character the first time you would set hasSpawned = true; Change your Application.loadedLevel to have and if check.

 if(hasSpawned == false){
     //spawn the player at the default spawn point
 }
 
 if(hasSpawned == true){
     //spawn the player at the new spawn point
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Negagames · Apr 22, 2013 at 09:06 PM

 var spawn : Transform[];
 
 function Start(){
     transform.position = spawn[Random.Range(0, spawn.length)];
 }


or

 var xMin = 0;
 var xMax = 0;
 var yMin = 0;
 var yMax = 0;
 var zMin = 0;
 var zMax = 0;
 
 function Start(){
     transform.position.x = Random.Range(xMin, xMax);
     transform.position.y = Random.Range(yMin, yMax);
     transform.position.z = Random.Range(zMin, zMax);
 }
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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Loading next level, but next level never gets incremented. 3 Answers

How to make a key to a portal ? 1 Answer

Play Scene help 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

level loader script wont work 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