How to Rotate a Tire Manually Without Flipping

Greetings, I’ve been building a custom setup for my racing game and I’ve run into a sort of road block. Now I decided early on that I didn’t want to use the built in vehicle components because I wanted a more arcade style feel for my vehicles, so I’ve built a moving car setup using suspension, hovering, etc. I still want tires attached to certain vehicles however and I want them to act as they would if they were physical objects.

This is where the problem comes in. I’ve decided to rotate the tires in two different axis for accelerating/reversing and turning respectfully. The forwards and backwards works just fine, no problem there. The issue with the turning, however, has thrown a wrench in the works.

My tires are being told to keep rotating back to a certain forward vector (the car) so they always face forward when the car isn’t turning. When they turn, they go right or left as normally. At a standstill, this works quite well. When I move, however, the pitch creates a problem. When the wheel has rotated 180 degrees, the wheel is now upside down and flips to achieve the goal I set it to. Now I’ve tried many different methods of getting the wheel to not do this, but I can’t wrap my head around the solution.

How do I get the tires to turn left and right, then return back to forward when the steering stops without being thrown for a loop when the tires are turning as they rotate during acceleration and reversing? Is there a way to do this via world rotation, rotate about axis, or perhaps some method of local or relative rotation that solves this issue? Because everything I’ve tried so far, only repeats the problem: It always wants to flip once the tire has rotate 180 degrees, then back again, and again, etc.

Any help you could provide me on this would be tremendously helpful, as I’ve been stuck on this for quite some time. I’m relatively new to Unreal, so I don’t know how to tackle problems like this despite the options I’ve approached so far.

Take a look at this video series, and you’ll find a solution how to setup everything, including wheels.

Here are some example images of what I’m currently doing. This one is how I’m currently rotating the tire when I accelerate or reverse. Forward Speed is calculated earlier and then this is repeated for all 4 tires. It works without issue, though of course when the tire flips it’s turning in the wrong direction. Though I don’t believe this code has to change much at all for this issue.

This is how I’m turning the tire when I steer using the a and d keys. When I’m not moving, this works perfectly fine and it returns to center using more code I’ll provide.

And this is how I’m currently returning the rotation back to center once I’m done steering. I didn’t know a better way to create a specific rotation to set it to, so I simply had it find the opposite rotation and then start adding it to each other. The code this extends to then zeroes it out when it reaches close to 0. A bit complex and unneeded, but it worked nonetheless. Of course, the big problem is once the tire rotates in pitch 180 degrees, the yaw becomes -180 or 180, thus forcing it to flip. Preventing that is the key here.

One final thing, for the steering rotation I’ve tried the following:

Using the forward vector for the wheel to determine a rotation to return to.
Using the forward vector of the car for the same.
Using world rotation instead of relative location.
Using rotate from x vector to determine a rotation to return to.

All of these resulted in the exact same problem. Rotation is really kicking my butt, I don’t know what else to try.

Well that’s the thing, I’ve already gone through those tutorials to create my first take of the vehicles, but I wasn’t happy with the set up because while the wheels, steering, and most everything else worked, the set up trapped me in working with gears, speed, and drifting that I couldn’t change. No matter how high I made the values or how I altered it, the car never got faster than a certain amount. This and a few other issues prompted me to make a custom car setup that didn’t use vehicle components, blueprints, or wheel blueprints.

While I would love to just use the wheel set ups, they require me to use the vehicle blueprints, which traps me within a certain threshold of car simulation. I don’t want a car simulator, I’m aiming for a more arcade feel with unrealistic physics.

I’ve managed to find a solution I’m happy with! Rather than having the wheel attempt to zero itself out by returning to a specific value or providing a vector for it to always return to, it was simpler to create a variable to increment by a certain amount when it turned, cap how far that goes, then use the same increment to wind back the turning on add relative location while also removing said increments.

This provided all the solutions I needed while ignoring the flipping of the tire entirely. It makes sense in hindsight, provide a focus for the rotating object to focus on an it’s orientation will of course go askew when you turn otherwise, but simply tell it to turn in a certain way a certain amount of times and it doesn’t have any reason to fight you.