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?
1 Answer
1var 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);
}
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?
– GC1983Make a static variable with the position you want the player to spawn at and spawn him at that?
– CaptainKirbyIn the start function change the spawn position?
– ahaykalThis is not an answer, its a question that leads to no resolution. Please use the comments to understand their problem better. Thanks!
– GC1983You would create your new spawn point and place it in the level. You would create a variable something like
– Glistervar hasSpawned = false;and when you spawn the character the first time you would sethasSpawned = 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 }