Hi guys!
Ive got this code, thats suppose to move a lantern toward the player and down to imitate a running effect, once it reaches a certain point, its suppose to stop which it is failing to do. (I will also add functionality for it to bob once i get this simple mechanic down pat)
Thanks!
Script:
var posZ = -0.5948148;
var posY = -0.6899948;
private var moveSpeed = 0.1;
private var orgSpeed = 0.1;
var lantern : Transform;
function Update () {
if ( Input.GetKey(KeyCode.LeftShift) ) {
if (lantern.position.z >= posZ && lantern.position.y <= posY) {
moveSpeed = 0;
Debug.Log("STOPPED");
} else {
lantern.position.z += moveSpeed * Time.deltaTime;
lantern.position.y -= moveSpeed * Time.deltaTime;
}
}
}
↧