# Rotation towards horizon

Hi, I’m trying to rotate my plane towards the horizon, no matter all the other rotations - as in the plane can be arbitrarily rolled, pitched, yawed.

I was able to find the needed rotation axis (taking forward vector, removing its z component and doing the cross product between the two), but I don’t want to rotate the plane directly, I need to use its yaw/pitch/roll controls.

How do I go from said cross product to rotations around each axis (how much to yaw and pitch separately)?
Alternatively, is there a simpler way of doing it?

Thank you.

Yeah, so I was on the right track, but that cross product was pointless.

If anyone is looking for something similar:
I took only the rotation from the actor rotator and took sin and cos from it… cos for pitch and sin for yaw - because the ratio of these controls is proportional to the rotation of the plane and nothing else (while plane is turned sideways, angle will be 90°, so cos will be 0, and sin will be one… which relates to the fact that I need to fix the plane with yaw, not pitch)

Then I needed to check if the plane looks to the sky or to the ground. I compared the actor forward vector with global up vector with the dot product. Zero is the ideal state, the horizon. + values are sky, -values are ground.

Now I can do stuff like ActorBody->ApplyTorque(ActorTransform.TransformVector(FVector(0,Yaw, Pitch)DotmaxForce)…).

I knew it would be something so simple, I just needed to use the Roll value itself.

PS: some steps might be unnecessary (sin cos might be), this is just “now it works” kind of code.