- Home /
Trying to make a checkpoint script
This is a script I'm working on for a school project. I've been trying to make a script that will respawn my character after they reach a certain point in my game...I've just can't get this to work. This is my first time posting and basically first time scripting for Unity.
Here is my script.
private var active1 = false; var exx = 1.5; var whyy = 37.25; var zeee = -18.82; var dead = false;
function OnControllerColliderHit(hit : ControllerColliderHit) { if (hit.gameObject.tag == "this")
{ active1 = true;
} if (active1 == true && hit.gameObject == "DEATHZONE"){ transform.position = Vector3(exx,whyy,zeee); gameObject.Find("Character").transform.position = Vector3(exx,whyy,zeee); dead = false;
} }
Thanks a bunch. Daniel
Answer by DaveA · Apr 28, 2011 at 10:06 PM
hit.gameObject == "DEATHZONE" looks very suspicious. Did you mean by 'name of DEATHZONE'? If so, hit.gameObject.name, if 'tag of DEATHZONE' then hit.gameObject.tag
Answer by zmar0519 · Apr 29, 2011 at 01:54 AM
I suggest a different logic. Look at the lerpz tutorial for a respawn script that uses static vars, not point to point logic.
Answer by Daniel MacIntosh · Apr 29, 2011 at 02:51 AM
I'm sorry I should have clarified what I was trying to do better. The game is a simple platformer where you jump from block to block to get to the end goal. If you hit the floor you are respawned at the beginning. I have been getting complaints from classmates that the game is to hard and needs a checkpoint system, so you are not sent back to the beginning of the game once you've gotten to a certain point.
I've checked out and used many of the scripts from Lerpz's tutorial and still can't understand what I need to do for this issue. I was thinking that I need to cancel out the original respawn point at the beginning so the player was able to start again from the checkpoint. Once it was reached. (The Checkpoint is a basic sphere tagged as "this")
DEATHZONE refers to the floor, once hit it calls for the character to be spawned at the beginning location.
Your answer
Follow this Question
Related Questions
Cannot move FPSController after respawning at a spawn point. 1 Answer
help with death zone/respawn 1 Answer
Character Re-spawn Problem 0 Answers
3d Platform tutorial respawn wrong location 3 Answers
Respawn Button 2 Answers