I want to set my root component Up vector to be equal to the normal of the floor the component is over.
My code is something like this :
FRotator UpRotator = MyRootComponent->GetUpVector().Rotation(); FRotator NormalRotator = Hit.ImpactNormal.Rotation(); FRotator DeltaRotation = NormalRotator - UpRotator; MyRootComponent->AddLocalRotation(DeltaRotation);
This almost works. The problem I have is that the component loose its local Yaw. Here’s a gif to illustrate the problem :
The solution is probably very obvious, but I can’t figure it out.