Hey everyone,
I’ve look for quite some times for this and I can’t find something really useful.
I am making a 3D platformer and I would like to add a delay to my moving platforms so the player has time to get on them. Here is my moving platform script:
var DestinationSpot: Transform;
var OriginSpot: Transform;
var Speed: float;
var Switch: boolean = false;
function Start () {
}
function Update () {
if(transform.position == DestinationSpot.position){
Switch = true;
}
if(transform.position == OriginSpot.position){
Switch = false;
}
if(Switch){
transform.position = Vector3.MoveTowards(transform.position, OriginSpot.position, Speed);
}
else{
transform.position = Vector3.MoveTowards(transform.position, DestinationSpot.position, Speed);
}
}
I know myself around ActionScript but I’m new to JavaScript. I thought the right way to do it is when the platform reaches its origin spot (or destination spot) it would wait for a certain amount of time, but I have no idea how to write it.
I’m looking forward to any answer