Hi i have this code in Update void
if (audiosource.isPlaying && audiosource.time = 10) {
Vector3 moveDirection = Vector3.zero;
moveDirection = new Vector3 (Input.GetAxis ("Horizontal"), Input.GetAxis ("Jump"), Input.GetAxis ("Vertical"));
moveDirection = transform.TransformDirection (moveDirection);
if (audiosource.clip.name == "HelicopterStartup") {
moveDirection *= audiosource.time * 0.005f;
}
if (audiosource.clip.name == "HelicopterShutdown") {
moveDirection *= (audiosource.clip.length - audiosource.time) * 0.005f;
}
if (audiosource.clip.name == "HelicopterIdle") {
moveDirection *= 30 * 0.005f;
}
CharacterController controller = GetComponent ();
controller.Move (moveDirection * Time.deltaTime);
}
When i press spacebar it should goes up
It works but when it starts to play HelicopterIdle sound the helicopter starts to move like it shouldn’t
I tried to put the code in FixedUpdate and it works properly but if i press spacebar continuously it flickers