I made an updated version of the script that was on my old post. Now all it makes the flashlight do is rotate in a circle around the x axis. the flashlight is supposed to go from (0, 0, 0) to (31, 0, 0) when sprinting, and back to (0, 0, 0) when not sprinting. Please tell me what i did wrong… again…
var rotationX = 0.0;
var sprintActive : boolean = false;
var breathingObj : GameObject;
var lightObject : Light;
var stopMovement : boolean = false;
function Update () {
rotationX = lightObject.transform.rotation.x;
if(sprintActive == true && stopMovement == false){
lightObject.transform.Rotate(Time.deltaTime * 120, 0, 0);
}
else if(sprintActive == false && stopMovement == false){
lightObject.transform.Rotate(Time.deltaTime * -120, 0, 0);
}
if(rotationX > 31 && sprintActive == true){
stopMovement = true;
}
if(rotationX < 0 && sprintActive == false){
stopMovement = true;
}
}
function Start(){
stopMovement = true;
while(true){
yield WaitForSeconds(0.1);
if(breathingObj.GetComponent(SprintScript).isSprinting == true){
sprintActive = true;
stopMovement = false;
}
else if(breathingObj.GetComponent(SprintScript).isSprinting == false){
sprintActive = false;
stopMovement = false;
}
}
}