I want to make a spawn point for my character.
A function that will make him spawn when he dies and something else when the level is won
How can i do something like this?
Please HELP!
To make a spawn point just create an empty game object and position it where you want your player to be spawned.
You then need to add a script to the player that sets the variable “respawn”(can be called anything) to true when his life points are down to zero.
I don’t really know how you’re determining wether the player has died, but I am assuming you used life points…
It could look something like this:
var SpawnPoint : Transform;
var respawn : boolean = false;
var PlayerLife : int;
function Update () {
if(PlayerLife <= 0)
{
respawn = true;
}
else
{
respawn = false;
}
if(respawn)
{
transform.position = SpawnPoint.position;
}
}
You will have to add the game object you created before (spawn point) to the slot called “SpawnPoint” in the inspector window.
This is a very basic script that will send your player to the position of the respawn point as soon as his life points reach zero.
This should help you get a simple respawn which you can customise to your needs, hope it helped!