Custom physic vehicle simulation! Project download included

Hi, probably the last update. Enjoy :stuck_out_tongue:

You should contact (@) to be featured on the Community Spotlight in one of Epic’s Streams. Just a thought.
Also, you could consider a Dev submission. Added sounds, maybe a couple different setup examples, some more tweaks to handling, I could totally see it worthy of a .

Hi! I am unsure this project is worth a but I did contact to hopefully get this project included as a starter project within the engine. So that can have acces to it :slight_smile: thanks for the sugestion.

Only one way to find out, nothing to lose here xD

I don’t think it would be a good idea to include this on a starter content as constraint based vehicles have their own share of issues.

I’ve done prototypes on this approach years ago and they are not stable at higher speeds on uneven surfaces or even on a perfectly leveled landscape. You can try yours by just putting a new landscape there and try to drive fast and steer. If constraint based vehicles worked properly on high-speed wheel collisions, everyone would use them instead of traces.

Edit-> I tested your cars on both empty landscape and on vehicledemo map, you can see the cars bounce off really badly even on a smallest bumps (or less precise collisions on landscape as there’s no bumps there). On landscape I just tried to drive a straight line without steering (which would have made the situation even worse).

I am not getting any issues on flat bsp box, dunno why you do, but yess the landscape collisions have always been a problem and I personally would probably use a static mesh for the terrain rather than landscape for that reason. But thanks for pointing this out!

oh and also, I am trying to use a trace method AND the physical wheel to work together, so that the physical wheel dont quite touch the ground on flat surfaces but come into play in the case of steps for examples, in wich a simple line trace wheel would clip through…

Probably you will problems too in non landscape meshes that aren’t flat ?

If the terrain is a static mesh you can get the collisions to be much more accurate, but I will have to run tests on that and see if I can fix this issue with the landscapes.

oh and I saw this in the 4.14.1 release note:
Fixed! UE-38716 Physics are popping in Vehicle Advanced Template

hope this may solve the problem had on flat bsp. Even tho I do not have that problem on my computer.

That fix is for unreal vehicle. I don’t use them, nor do you :slight_smile: It’s a fix done on physx vehicle suspension code. Also, I didn’t have an issue on flat bsp, what I screenshotted was from flat landscape (although flat bsp wasn’t fully stable at high speed either).

You pretty much need that for constraint approach too as collider wheel may slightly bounce all the time is surface isn’t perfectly even. I also recommend doing a slightly longer trace than what you’d do to reach the ground so you can keep adding tire forces still. I didn’t check your setup but if you use cylinder shape for wheels, swapping that to sphere collision would help a bit on nasty collisions but not totally cure it. Of course, it wouldn’t act right when vehicle is at two wheels.

I do already use a sphere collision as the wheels are skeletal meshes with a physic asset. I noticed soon enough that a cylinder mesh would never be round enough to avoid the bouncing.

I disabled CCD and “Always create physic state” on the wheels and the jumping bug stopped completely on the flat BSP. Time to try the landscape.

Tried it with the changes from the last video on a race course asset, I have to say, it’s pretty satisfying right now.
Really like how it’s coming together.

One suggestion for a future feature (of the type “nice to have”) - camera shouldn’t rotate with the car when it flips.
The VehicleGame in the Epic launcher has this implemented.
I’ll have a look at how they set it up, probably in C++ but shouldn’t be difficult to port to BP.

im glad you like it ^^ and do you mean I should actually detect when the vehicle is fliping and stop the spring arm from heriting the rotation of the vehicle? or at all time?

Maybe they simply ignore the roll component, or limit the roll to certain degrees.

Ok, forget that, just had a look at how it’s set up in the VehicleGame example, it’s just “inherit roll” and “inherit pitch” turned off on the Spring arm (thought it was something more complicated). So yeah, never mind.

Whether real car would jump or not on bumps depends heavily on the suspension tuning. For example, dampeners on real cars don’t react with the same force when suspension stretches or contracts, for a simple reason of preventing wheel being pushed into a ditch and reacting faster to hitting a bump, at the same time. I don’t know if you can simulate this with a physics constraint, I had to use custom springs for this. Constraints are rather limited to how you can tune them, with all kind of “simplifications” under the hood where force of the drive is scaled by the mass of the constrained parts…
The other issue with using constraints for suspension is that they push with the same force on the wheel as they push on chassis, which is physically correct but depending on mass ratio of wheels to chassis can lead to wheels being pushed into the ground and then immediately being pushed out. Which leads to jittering. This gets more aggressive when time step varies or when frame rate goes down.
The next thing is constrained objects penetrating other objects and getting stuck into them, this is something that you don’t have control over. Imagine playing Mad and getting propelled into a space every 5th time you collide with someone on the road :smiley:
Replacing landscape with static meshes can be an option, but it can take a lot of labor to make a “proper” collision for them, unless you are doing Complex as simple collision, which won’t be good for performance with many cars and large static meshes.

There are applications where constraints just minimize amount of work that have to be done otherwise, like in case of this thing:

as I don’t need to code a logic of what happens if one aerosled drives over another. But at the same time collision of two vehicles like this can get them stuck, like if ski gets into propeller protection frame. Which is not desirable for a gameplay and better be handled by rules, instead of having a random outcome.

An amazing example of using just constraints:

unfortunately moving at high speed is a bit of an issue for it.

At the end of the day, if you are adding raytraces to help you with stability, why not go for sweeping a cylinder?

in the video you linked, the guy is using a cylinder mesh for its wheel collisions, how many times am I going to say this x) of course this solution does not work. wich is why I dont do it. My goal is to make this vehicle class as reliable as the wheeled vehicle class provided with the engine, exept much easier to setup. You may have noticed that the default wheeled vehicle class require very specific workflow to setup a vehicle using it, you need to skin the mesh, offset the wheels collisions to be at the right location to match the wheels, and so much more. People are more than often left with very unsatisfying results. Wich is what I am trying to solve with this. It is not perfect just yet, the default class is far from perfect too. But I hope some people still find it usefull, or at least that it allowed some people to learn things.

have a good day!

Edit: you can clearly see in my videos that the vehicle is going over 170 km/h. and the wheels are not bouncing around. Even on landscape. And because I chose static mesh terrain does not mean it does not work on landscape! Just give the project a try, tweak the values as you like and you’ll see :stuck_out_tongue:

Well, good luck with it!