- Home /
Question by
lorigio · Jul 09, 2012 at 04:16 PM ·
helicopter
Helicopter flight
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
Comment
Answer by Ingen · Jul 09, 2012 at 05:14 PM
Hallo, I think is becouse you use CharacterController, and it is setting to make jumpig the player
try to use another key
by