x


Script problems

hey guys when i enter my trigger this script keepts triggering it doesnt stop my transporter keepts transporting me

i want it to trigger once ontrigger enter in once in 10 sec so the player is not able to trigger the trigger again for 10 sec`s ???

 var destination : Transform;

function OnTriggerEnter(other : Collider) {
     yield WaitForSeconds (6);
     time  = -(6);
     other.transform.position = destination.position;
}
more ▼

asked Jan 29 '11 at 09:09 PM

Wesley S gravatar image

Wesley S
65 37 43 48

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

1 answer: sort voted first

I've not tested this but I think it should be something like this,

var destination : Transform;
var canTriggerTime : float;

function OnTriggerEnter(other : Collider) {
    if(canTriggerTime == 0) {
        //set the time to 10 seconds
        canTriggerTime = 10;
        other.transform.position = destination.position;
    }
}

function Update() {
    //check and stop trigger time from going less than zero.
    if(canTriggerTime > 0) {
        //subtract deltaTime from trigger time 
        canTriggerTime -= Time.deltaTime;
    } else {
        //set to zero to stop it from going below zero
        canTriggerTime = 0; 
    }
}

I'm just learning myself and I also don't use UnityScript I use C# but I think it should be something like this.

more ▼

answered Jan 29 '11 at 10:12 PM

DanMarionette gravatar image

DanMarionette
177 11 12 21

(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:

x3344
x256
x91
x8

asked: Jan 29 '11 at 09:09 PM

Seen: 416 times

Last Updated: Jan 29 '11 at 09:09 PM