So I am working on this diving game prototype that I posted about earlier, and I am a complete 'tard when it comes to scripting so I therefore need some help with this one.
I need the make the player respawn back on top at the diving board a couple of seconds after hitting the water.
I tried to look at the Lerpz 3D tutorial, but can't seem to figure out how to make it work in my own project. Any clues on how to do this?
What I think I understand by now is that I should create a collision object in the water that makes the player respawn at a selectet position (spawnpoint) after hitting it.
You can attach something like this to your water, though you'll have to make sure the player has a rigidbody and collider, and the water has a trigger collider:
var spawn : Transform; //drag your spawn point to here in the inspector - probably make it an empty gameobject so you can move it about on the diving board
function OnTriggerEnter(other : Collider)
{
if (cother.tag == "Player")
{
other.transform.position = spawn.position;
}
}
Fantastic :)) Works great man
Thank you !!
For 2D script looks like this:
var spawn :
function OnTriggerEnter2D(other : Collider2D) {
if (other.tag == "Player")
{
other.transform.position = spawn.position;
}
}