Rotating flaps, fins etc, on a plane gradually.
Hello people,
I have been searching around for a while, but to no awail. I am trying to make the fins of a plane rotate, until they have reached a specific angle, then stop. However, no matter how much I have tried, I can't come to a solution.
public Transform pitch;
public Transform yaw;
public Transform rollL;
public Transform rollR;
I have these public transforms to use, and I am using an axis as input so that I can make them pitch correctly with controllers later, when I figure this out. So I want to use an if-statement like this:
if (Input.GetAxis("Pitch") < 0)
{
}
I have added these in the input-manager, and it works correctly with a negative, and postive button. I can't for the life of me figure out how I can get them to rotate correctly, and then stop.
Any help would be great!
Answer by Jonastrek · May 04, 2018 at 07:05 AM
I came up with a solution just before falling asleep last night, and now it seems to be working just fine. It was way simpler than I realized.
float pAngle;
pAngle = pitch.localRotation.x + Input.GetAxis("Pitch") * 25;
pitch.localRotation = Quaternion.Euler(-pAngle, 0, 0);
Since the Axis of the pitch goes between 1, and minus 1, you can get a pretty good rotation with tweaking the "pAngle" variable to you own liking. I'm pretty sure something that looks like this would work great for a controller based car game (Wheels, and turning) as well.
Your answer
![](https://koobas.hobune.stream/wayback/20220612161839im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
unity 5 stopping 0 Answers
How can i rotate an object using LookAt with only 1 axis? 0 Answers
Know when the object is rotated? 1 Answer
Object rotates normaly while moving, then does zig zags? 0 Answers
How to move an object on a 2d plane forward, backward, and in a rotation about the mouse position? 0 Answers