- Home /
Helicopter rotor inclination
Hi i have made my helicopter rotor works but when i use left/right arrow keys and the helicopter inclination changes it looks like this
Here the video http://www.youtube.com/watch?v=_3fehYSxVSw
Here like i want it will be
This is the code for rotor spin that cause the problem
MainRotor.RotateAround (MainRotor.position, Vector3.up, audiosource.pitch * rotorspeed);
And this for the helicopter inclination
moveDirection = new Vector3 (Input.GetAxis ("Vertical") * -1, Input.GetAxis ("UpDown") * -1, Input.GetAxis ("Horizontal"));
moveDirection = transform.TransformDirection (moveDirection);
moveDirection *= speed;
if (Input.GetAxis ("Vertical") > 0 && (transform.rotation.eulerAngles.z <= 20 || transform.rotation.eulerAngles.z >= 339)) {
transform.Rotate (Vector3.forward * Input.GetAxis ("Vertical") / 10);
} else if (Input.GetAxis ("Vertical") < 0 && (transform.rotation.eulerAngles.z <= 21 || transform.rotation.eulerAngles.z >= 340)) {
transform.Rotate (-(Vector3.back * Input.GetAxis ("Vertical") / 10));
}
if (Input.GetAxis ("Horizontal") > 0 && (transform.rotation.eulerAngles.x <= 20 || transform.rotation.eulerAngles.x >= 339)) {
transform.Rotate (Vector3.right * Input.GetAxis ("Horizontal") / 15);
transform.Rotate (0, Input.GetAxis ("Horizontal") / 15, 0);
} else if (Input.GetAxis ("Horizontal") < 0 && (transform.rotation.eulerAngles.x <= 21 || transform.rotation.eulerAngles.x <= 340)) {
transform.Rotate (-(Vector3.left * Input.GetAxis ("Horizontal") / 15));
transform.Rotate (0, -(Input.GetAxis ("Horizontal") * -1) / 15, 0);
}
CharacterController controller = GetComponent ();
controller.Move (moveDirection * Time.deltaTime);
Hard to see what's wrong on your screenshot - do you have a better image; can you explain what's wrong in the screenshot?
the rotors are angled left indicating the chopper is rolling(banking, turning) left, but the chopper body is not the same angle as the rotors. sry I couldn't help except in that, good luck =]
Are you blades children of your chopper? If the input axis is in world co-ordinates, you'll need to specify Space.World or map the axis into the rotar blades coordinate space.
I've not checked your rotate maths here - if the chopper is at the origin in your world and has no rotation applied to it, do the rotars move as expected?
Yes blades are children of the chopper, i'll post youtube video in 5 $$anonymous$$utes
Answer by lorigio · Jul 10, 2012 at 10:27 AM
Solved by replace
MainRotor.RotateAround (MainRotor.position, Vector3.up, audiosource.pitch * rotorspeed);
with
MainRotor.RotateAroundLocal (Vector3.forward, audiosource.pitch * rotorspeed);
I think Vector3.up would have been 0,1,0 always, I don't know if you needed to use Transform.up from the blades?
Your answer
Follow this Question
Related Questions
Camera control as helicopter 0 Answers
how to create enemy AI helicopter/flying object in 2d game?? 1 Answer
Error with my C# script for my helicopter 2 Answers
Sci-Fi Assault Craft 2 Answers
Helicoper Movement Help 1 Answer