Hi all,
I am trying to find a way to make the below script work locally as opposed to world coordinates.
For example, I’d like to constrain the boundaries of a sphere so it can only move a certain distance from it’s original center point.
Any ideas?
public var waiting : boolean = false;
var randomPosition : Vector3;
var moveDelay : float = 1;
function Update ()
{
if (waiting == false)
{
SendMessage("LerpCube");
}
else
{
transform.position = Vector3.Lerp (transform.position, randomPosition, Time.deltaTime*1);
}
}
function LerpCube()
{
randomPosition = Vector3 (Random.Range( -1.62, 2.14 ), Random.Range( 2.42, -2.11 ), Random.Range( -0.00916, -0.00916));
waiting = true;
yield WaitForSeconds (moveDelay);
waiting = false;
//Debug.Log ("waited");
}
//randomPosition = Vector3 (Random.Range( 6,-6 ), Random.Range( 4, -4 ));