I’m tweaking the example code to make a platform object move between two empty gameobjects (linked to with the opening variables) the code is attached to the platform:
var start : Transform;
var end : Transform;
function Update () {
var startingpoint; //what goes here?
var endpoint; //and here?
if (transform.position == start.position) {
startingpoint =start.position;
endpoint = end.position;
}
if (transform.position == end.position) {
startingpoint = end.position;
endpoint = start.position;
}
transform.position = Vector3.Lerp(startingpoint , endpoint, Time.time);
}
I’m not an uber-coder tbh I just want to use simple code to check when the platform arrives at the first guide and then travels to the second, then back to the first, indefinitely.
Within the update function, i’m trying to define some temp variables (startingpoint , endpoint) to hold the Tranforms. Then swap them.
Question is: how do I define the variables? I’ve a feeling I should use a vector3, but I’m not sure of the syntax.
(PS: I’d like to get this piece of code working, no matter how bad it is )
Thanks in advance.