I have this small level with three different respawn points. I want to make the player respawn on a specific respawn point depending on the player performance.
To be more specific… If the player manages to to 5 tricks/double jumps in midair he/she respawns on reSpawnPoint 2, and if the player manages to pull of 15 respawns on point 3 and so on.
How do I implement this into the respawn script?
var reSpawnPoint1: Transform;
var reSpawnPoint2: Transform;
var reSpawnPoint3: Transform;
var timer : float = 0.0;
function Update ()
{
if(gameObject.transform.position.y < -3)
{
timer += Time.deltaTime;
if(timer>5)
{
timer = 0;
gameObject.transform.position = reSpawnPoint2.position;
}
}
}
I know I ask a lot of questions on this forum, but I really need all the help I can get.
Do you have a variable somewhere that keeps track of how many tricks (or whatever) the player has accomplished? If so, can’t you just use a series of if-else statements? E.g.:
If you want something more flexible, you could create a container mapping number of tricks to spawn points (this way you wouldn’t be locked into specific threshold values or a specific number of spawn points).
Yes I use a GUITexture script with a static variable to the Character controller script. It animates the GUItexture every time the space button is pressed.
This is my GUItexture script:
var reSpawnPoint1: Transform;
var reSpawnPoint2: Transform;
var reSpawnPoint3: Transform;
var timer : float = 0.0;
function Update ()
{
if(gameObject.transform.position.y < -3)
{
timer += Time.deltaTime;
if(timer>5)
{
timer = 0;
gameObject.transform.position = reSpawnPoint2.position;
}
}
}
This is the part of the character controller script that animates the GUItexture:
Hehe I have been tinkering with it for a couple of hours now, but still don’t understand to much when it comes to JS. :S All help is much appreciated, though I wish I learned faster.