- Home /
Respawn after falling off script?
Greetings, I am currently creating a game where you have to jump from one cube to another and not fall off. I was wondering if there was any way that I could make it so the player respawns at the original spawn point after falling a little distance. Does anyone have scripts for my request? I am having a very hard time with this as I am quite new to Unity. May you explain in detail exactly what I do to have the player respawn on the original spawn point after falling off? I already created a invisible large rectangle under the map so the player falls off and lands on it. Now what do I do after this? How do I make it so the player teleport to the spawn point after hitting the invisible platform?
Answer by gnubberlang · Oct 29, 2012 at 11:02 PM
That should be pretty easy. I would think you could just do an "ApplyDamage" kind of setup like the FPS tutorial and die after falling, or maybe set up the invisible block's oncollision to place the player back at the start.
Answer by ZenithCode · Oct 29, 2012 at 10:33 PM
Wherever you have the logic that shows your player has fallen off screen do this, Application.LoadLevel(Application.LoadedLevel)
I have set up something so that if the player falls off, it restarts the scene, but I don't like it. I want it so that my other scripts (Such as a timer or lives) do not restart when the player falls off.
Ok. There is a simple solution for that problem.
Save the information you would like to keep in PlayerPrefs (stored in memory)
Check this out and let me know if you have trouble using it!
http://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html
Your answer
Follow this Question
Related Questions
Falling off respawn 4 Answers
How to make an object spawn in different positions? 2 Answers
Falling off respawn script 1 Answer
Random cube length on instantiate... 1 Answer
change gravity after time 1 Answer