- Home /
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?
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?
$$anonymous$$ake a static variable with the position you want the player to spawn at and spawn him at that?
This is not an answer, its a question that leads to no resolution. Please use the comments to understand their problem better. Thanks!
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
}
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);
}
Your answer
Follow this Question
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