x


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

more ▼

asked Apr 28 '11 at 09:50 PM

Daniel MacIntosh gravatar image

Daniel MacIntosh
2 1 1 1

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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

more ▼

answered Apr 28 '11 at 10:06 PM

DaveA gravatar image

DaveA
26.5k 151 171 256

(comments are locked)
10|3000 characters needed characters left

I suggest a different logic. Look at the lerpz tutorial for a respawn script that uses static vars, not point to point logic.

more ▼

answered Apr 29 '11 at 01:54 AM

zmar0519 gravatar image

zmar0519
946 59 66 78

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Apr 29 '11 at 02:51 AM

Daniel MacIntosh gravatar image

Daniel MacIntosh
2 1 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x184

asked: Apr 28 '11 at 09:50 PM

Seen: 930 times

Last Updated: Apr 28 '11 at 10:04 PM