I am designing a racing car game using a proprietary physics engine that I am plugging in. It does not have support for outputting Z positions or Roll and Pitch as that depends on track geometry. Is there a way to get these values from the point on the terrain directly beneath the actor?
Off the cuff, the best I can come up with is to run a line trace from the bottom of the vehicle down. The hit result has an ImpactNormal. You should be able to get a rotation relative to “flat” from that.
Would you happen to now how to take the normal and convert it to a Flat Vector from there? I see that it returns a Normal FVector which I should be able to convert using FRotator
Not really sure what you mean by flat vector.
FRotator and FQuat can transform a vector.
You can take FVector::ForwardVector and run the rotator TransformVector function to get a vector that points in the direction of a rotator. I forgot exactly what the function is called.
However that is actually exactly what the impact normal vector already is.
Or if you want a rotator from a vector, vector has a function to return a rotator. Or maybe it was the other way around and rotator or what has a function to set itself from a vector. Also what and rotator can convert between each other.
Sorry what I meant was how would I get the supposed rotation and pitch of the Actor if I hit the ground using the normal vector was my question
You would probably want to take what the actor’s rotator is without the normal vector applied as if it was floating in air. Get the vector from that.
Then take the normal vector of the impact.
Find the relative rotator between those 2 vectors, and apply that rotator onto the actor’s original rotator.
There might be even more optimized ways to do it, but that should be a start.