- Home /
2D Platformer - How do I have objects that kill the player upon touch/cause respawn?
Walking the player into spikes causing a respawn would be a good example.
Is there any way to do this, like a script I can input, or an easy explanation? I'm quite new to unity. All help is appreciated.
I'm not sure if you should use a Trigger or Collision , but you could use any of those two to check if the player hits the spikes and set the players position to some empty game object that works as the spawn..
For example..
Transform spawn; //assign this in the editor
OnTriggerEnter(Colider col){
if(col.gameObject.name.Equeals("player)){
col.gameObject.position = spawn.position;
}
}
or something along those lines..
Answer by Ercandil · Jan 05, 2014 at 06:09 AM
You can set object working as respawn point and transform player to this resp point on collision with spikes for example.
Answer by lloladin · Jul 14, 2015 at 10:02 PM
if you are new to unity i would recomend following a tutorial
i would recomended this guy since he spends alot of time explaining stuf
https://www.youtube.com/watch?v=ndYd4S7UkAU
he also shows you some other basic stuff you probly want in a 2d game
but its pretty much what SahdoX explains it
Your answer
Follow this Question
Related Questions
Unity 2D player sticks on platform corners 2 Answers
2D Platformer queries 1 Answer
Particle System Won't Play At All 0 Answers
jittery collisions 2d platformer 1 Answer