[DEMO] Advanced Physics Constraint Vehicle

Hello Everyone!

Apologies for the long post, I’ll post a quick overview first and a more in-depth description below of the setup/drawbacks & my future plans, plus some questions I have for anybody who’s interested or may be able to help me out. I’ll also update this post as I make changes and updates. [HR][/HR]
Overview

This is a project I’ve been working on for the last few weeks, it’s a vehicle built entirely from constraints (10 to be exact) with a full engine, transmission, differential & suspension simulation. It’s built 100% in Blueprints, so everything is data driven and editable. Curves for Torque, Spring Forces, Damper Forces, Gear ratios etc. Has a nice natural feel in my opinion, but has some problems **(explained below). **As it stands you can create N wheeled vehicles with this, but it requires some setup, so once the simulation is tight and feeling good, I’ll focus on trying to make it as modular and user friendly as I can to make this easier. There’s currently quite a few specific data dependencies (e.g. functions that assume 4 wheels) that need to be more generalised in order for this to work.

If you just want to download the demo and try it out then the setup and download is below:
Basic UI in place to demonstrate forces etc.

Demo Vehicle Setup:

The vehicle is set up as a heavy, softer suspension off-road vehicle to better demonstrate the suspension capabilities so don’t expect amazing handling at high speed. But it’s still quite quick in terms of its size and mass and handles well in my opinion. Bear in mind this is still WIP.

**Weight: **2420 Kg
0-60: ~8s
Top Speed: ~115 Mph

Engine:
Max Torque: 425 Nm @ 3100 rpm
RPM Range: 1200 – 4600
(these settings are representative of an older V8)

Transmission:
Gears: 4
Ratios: 3.5, 2.25, 1.5, 1, (Final Drive: 3.0)
Mode: Auto*(Primitive, still WIP)* + Manual

Differential:
Mode: Limited Slip Diff 4W
**Threshold: **30%

Suspension:
Springs: Linear compression/force curve
Dampers: Sinusoidal(ish) velocity/force curve *(higher velocity = higher resistance). *Split into rebound & compression (higher resistance on compression than rebound)

Download Demo](https://drive.google.com/open?id=1DOgPHyfI9dWg4Pl2RkRpUPNZnniyll-3)
I plan to add some controls to the UI soon to allow people to adjust the vehicle setup and see how it responds.

Controls:
Movement: WASD
Gears: Q=Down E=Up
Handbrake: Space
Free Look: RMB
Roll Vehicle: R
Toggle Transmission: T

Gamepad is standard vehicle controls with A+X for Up+Down shift and Handbrake on RB

This is a more realistic feeling vehicle, so going full throttle round every corner will likely result in loss of control, especially on more slippery surfaces. Take it easy and get a feel for it.** I recommend using a controller for the best experience.** [HR][/HR]
More In Depth:

Setup:
The vehicle is built as one BP consisting of 13 static meshes (9 simulated), 10 constraints & 2 skeletal meshes (Suspension). It’s quite a lot of components, but through my testing so far seems to be pretty lightweight (although I’m no expert at debugging and profiling so feel free to check the stats in the demo using the console and let me know).

I did try separating the main parts into their own actors with their own logic to try to reduce the component count, but getting all the constraints and meshes talking to each other correctly required way more setup and was actually less efficient and stable. Separating out the engine simulation etc. works just fine but it’s just an extra component to add to the count and requires certain data from the base BP anyway so can’t be used independently and may as well just be left in there. I’ll post a screenshot below so you can see the mesh hierarchy and the settings that are exposed currently.

The meshes are super basic for now, just to give you a good visual representation of what’s going on.

Current Issues/Drawbacks:

Wheel friction & collision:
Capsules have been used for wheel collision, as cylinders (no matter how tessellated) produce wheel bouncing at high wheel RPMs as they need a mathematical curve to run smoothly. They also tank FPS in complex on complex scenarios. I chose to use capsules instead of spheres because the tyres need a flat contact surface to generate the necessary grip. The obvious drawback of this is unwanted collisions on the hemispheres and the lack of a defined edge to aid in lateral grip, causing some understeer issues. There’s no real fix for this besides writing a cylinder collision primitive into PhysX, which is beyond my scope, and from my research very performance heavy also. The extra collision on the wheels is very noticeable in tight areas, and also causes the vehicle to roll onto the hemispheres in certain situations.

Not being able to change friction of a physical material at runtime means I can’t modulate friction based on slip angle and I can’t reliably simulate tyre stiffness. Therefore the tyres are at a constant value which doesn’t feel right, once grip is lost it’s difficult to regain due to the shape of the capsule (needs a more defined outer edge). Swapping out physical materials has a noticeable jerky effect at high speed.

Braking:
I wanted to simulate braking using an angular velocity drive attempting to stop the wheels (rather than reverse Torque which isn’t realistic). This works ok, except the velocity drive seems to be a relative force; At high speed it locks the wheels up and causes the car to flip (unless only applied to the rear) and at low speeds it does nothing, even with a force of 10 Trillion. The other option is to use angular damping on the wheel hubs, but this has the unwanted effect of** locking the vehicle in a straight line under braking** (Would be nice to be able to set damping on a per axis basis). So in the end it’s currently a mixture of the two methods, using a drive to slow the wheels and damping to stop the car from flipping. However there is a lack of control under heavy braking, which I guess you’d sort of expect.

Future:
My plan for this is to release it to the marketplace eventually, I know there are other vehicle plugins and options available, but as far as I know this is the only full BP constraint driven vehicle with this level of depth and customisation. Please let me know if you have experience with any others and how this compares, and if this is something that people would be willing to invest money in. I’d love to release it for free, however I’m not exactly rich and if I can make a little money from the time I’ve invested in this then it’ll really help me out. If it gets a positive response then I have plans for a lot of other content in the future, some related to this, some not.

**UI: **
I’ll add some basic controls to the UI in the demo so people can play with them to test different setups in future:

  • Torque Multiplier
  • Spring & Damper multiplier
  • Ride Height & Travel
  • Transmission Settings
  • Differential Settings

Simulation:
I’m in the process of adding a turbo component, a supercharger component and a much more complex automatic gearbox. I also have a basic working tyre compression using the vertex shader, but these needs much more work and currently relies on distance fields.

General:
Eventually I want to try to replicate this as best I can, but this will be very difficult or maybe even impossible, so may take a while. [HR][/HR]
If you made it this far, you’re a hero, thanks for reading it all! If anyone can help me with any issues or just wants to leave feedback, please do. I look forward to hearing peoples opinions. [HR][/HR]
Here’s link to a useful article if anyone wants to try building something like this themselves or wants a better understanding of the physics of vehicles. It’s old but still relevant.

http://www.asawicki.info/Mirror/Car%…r%20Games.html

2 Likes

Hi People!

Quick update.

I have now added the simple skeletal mesh setups for the suspension, implemented the Limited Slip Diff and fixed some of the issues surrounding friction and handling. I’ve updated the OP to reflect the changes, and changed the link to the new version of the demo, which is now a .zip also as I had forgotten last time. Any feedback on this will be much appreciated! I’ll post a quick screenshot below of the UI as well, so you can see the differential etc. at work

I know it’s been a couple of years, but do you still have that project? The Google Drive link is broken now.

Very cool! The google drive is no longer working. Also did oyu ever figure out a good way for braking and wheel collision?