Hi.
I try to move a object up, wait for some seconds and the move it down again, and then start the movement over and over again. Like a continuous lift so to say but without any Player to trigger it.
In the Unity documents I found a script doing something close to this, but I don’t get it right when I tries to make it loop forever. When I compile it Unity complain about a cycle… but that is what I want isn’t it?
var startMarker: Transform; // start her
var endMarker: Transform; // stopp her
var speed = 1.0;
var smooth = 5.0;
private var startTime: float;
private var movementDistance: float; // distance between the markers
function Start() {
startTime = Time.time; // Keep a note of the time the movement started.
}
function Update () {
GoingUp () ;
}
function GoingUp () {
movementDistance = Vector3.Distance(startMarker.position, endMarker.position);
var distCovered = (Time.time * speed);
var fracJourney = distCovered / movementDistance;
transform.position = Vector3.Lerp(startMarker.position, endMarker.position, fracJourney);
yield WaitForSeconds (5);
GoingDown () ;
}
function GoingDown () {
movementDistance = Vector3.Distance(endMarker.position, startMarker.position);
var distCovered = (Time.time * speed);
var fracJourney = distCovered / movementDistance;
transform.position = Vector3.Lerp(endMarker.position, startMarker.position, fracJourney);
yield WaitForSeconds (5);
// GoingUp () ;
}