Rotation Inversion issue?

So I have a game where I’m trying to grind along a spline and the direction you go along it can change depending on the angle of entry. The direction works fine, I used vectors and dotproduct, all’s well. The problem is setting the rotation of the player properly when going backwards if the rail is set at an angle.

Here’s how I’m setting the rotation:


		FRotator NewRot = grindSpline->GetRotationAtDistanceAlongSpline(distAlongSpline, ESplineCoordinateSpace::World);
		SetActorRotation(NewRot);

If the rail’s angle is 0, SetActorRotation(NewRot.GetInverse()) works. However if the rail object is at an angle, it doesn’t. Going forward works perfectly no matter what, the inversion breaks when the object is at an angle. I don’t understand what’s going on or how to rectify the situation.

Any suggestions would be appreciated.

Hi LockeKosta,

It would only be the Yaw you’d want to inverse isn’t it? you could just do something like NewRot.Yaw+=180.0f; or NewRot.Yaw*=-1.0f…

I literally thought of that just as I posted this and have been changing it over to try it. XD

1 Like

It appears I completely messed up posting this and forgot to post it as a question or else I’d set your message as the solution. I’ve been basically screwing up the rotation setting this whole time. Changing it to just take the Yaw solved the problem.

Thanks for responding. ^^

1 Like