Clamp Rotation Beyond 180 Degrees

I am trying to have a steering wheel that turns 450 degrees both left and right, but every time I set the well to turn any degree beyond 180 I end up with an endless rotation. Adding a clamp converts any number greater than or equal to 360 into an equivalent angle between 0 and 359. Is there any way to clamp numbers greater than 359?

3 Likes

The engine ‘simplifies’ things by flipping between +/- 180. So, unless you want to use quaternions, you’re stuck with setting the wheel in some way between +/- 179.

Having said that, you can use ‘add local rotation’ as much as you like, and you will never get any flipping between values.

Maybe try using ‘add local rotation’, but keep your own copy of the sum, so you can check if it’s 450 or less?

PS: You will also have problems if the rotation of the wheel, by default, is not 0,0,0. You can get it in correct starting position, and then add it to a empty scene component, to achieve this.

2 Likes

I appreciate your response. Unfortunately, I have not been able to find a solution using quaternions or add local rotation. When attempting to add quaternion functions with C++ to my project they failed to compile in UE5.4 and using add local rotation resulted in the wheel spinning endlessly without any user input.

Here is my current set up for 180 degree turns:

Overall, what I’m attempting to do is create steering wheel turn animations like those found in Asseto Corsa, The Crew Motorfest and Driver San Francisco just to name a few. I know how to do the 90 or 180 degree turns with hand IK but I would like to learn how to make the hands shift gears, honk horns, change the radio, and change positions depending on the turn angle.

2 Likes

You can do something like this

You see, you have to manage the local rotation yourself.

This is very very basic, because the next step is to modify the turn speed, depending on how far away the target is, but you get the idea. ( Also centering needs to be added ).

steer

2 Likes

It works! I even made a few tweaks to it so that it turns back to the center position when there’s no turning input while accelerating. Do you happen to know why the target angle isn’t able to be used to match the animation movement to the wheel? I tried using the float value to control the animation play rate, but when I stop turning, the animation continues playing in the direction it was when I triggered the turn.

Also, if you know where I can learn more about how to manage tasks manually, I would love to learn more about that sort of thing.

1 Like

I have no idea about the animation, I’m afraid, I don’t use that part of the engine :slight_smile:

There is no common source of ideas like this. After you’ve been working with the engine for a while, you get used to making it do what you want :rofl:

2 Likes

Well, I appreciate the help, nonetheless, thank you!

1 Like

I figured out how to add the animations properly! I made a short video showcasing the animations I made. Thanks for your help once again.

1 Like

Excellent :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.