UE1 - UT Aligning player to surface

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Poor

New Member
Nov 24, 2013
2
0
0
I am making a vehicle mod for an older Unreal game. I want the vehicle to be parallel to the surface it is on so it looks more realistic when going up and down hills. The Yaw of the vehicle depends the direction the car is facing and the Pitch and Roll should be determined in such a way that the vehicle remains aligned parallel to the surface. Using Trace() to get the normal of the plane the vehicle currently resides on, how can I determine the proper Pitch and Roll values for the current Yaw value?
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
You can construct a rotator from axis vectors using OrthoRotation. You already have the Z vector, that's the surface normal. By converting the pure-Yaw rotator into a vector you get a facing direction D. Normal(Z cross D) will be your new Y axis vector. Then, Y cross Z is the X axis vector. Pass it all into OrthoRotation and you have the rotation for your vehicle.

Usage hint on the cross product operator and rotator axes:
Use your left hand's thumb, index finger and middle finger. Thumb points upward, index finger forward, middle finger to the right.
Index = X, Middle = Y, Thumb = Z.
Thumb cross Index = Middle.
Index cross Middle = Thumb.
Middle cross Thumb = Index.
Result is in opposite direction if you swap operands.
 
Last edited:

Poor

New Member
Nov 24, 2013
2
0
0
Thanks! This worked well. A lot more simple than the rotation matrices other people told me I needed.