Custom physic vehicle simulation! Project download included

How do you add Fake wheels? where does he show it during his tutorial videos?

I had my virtual toyota supra accelerate right up to 350 km / h - it is possible and up to 400 to try.[video]https://youtu.be/wmSyPmI536Q[/video]

hi Ivan Novohilov, I watched the video and I will try that code you posted. Thanks for taking the time to do all that and sorry I was away the last 2 months, I was kinda busy x)

Some screenshots of the menus Iā€™ve implemented for the project :slight_smile:

Hey JX53mb,
Iā€™m giving your physics a test using my own models and Iā€™ve followed your instructions as best I can. My cars are completely uncontrollable though. I think my problem seems to be that the collision for the wheels has a radius of a minuscule amount. I donā€™t know why this is. The cars (not scaled in any way) are of similar size to your example car, but the radii of the wheelā€™s collision is like .3, which is wrong, it should be ~30. I even tried with a blank project and Iā€™m still getting this issue. If it helps Iā€™m using Blender, whereas you use 3DS Max. But I wouldnā€™t think that would matter because theyā€™re importing in a similar size.

Can you help me at all

The size is pretty weird, but you forgot to apply the physical material to the wheel collisions in the physic asset. So the car must feel like driving on super polished ice x)

I applied the physics materials to the wheel collision of the black car, and the video attached is the result. The same thing happens to the Camaro if I apply it to itā€™s wheels. The black car behaves similar to the Camaro when it is lacking the physics material. If anything, the physics material makes the problem significantly worse. Itā€™s really strange and I do think itā€™s got something to do with the size of the wheel colliders

Hopefully youā€™re able to help after seeing the problem on Youtube. If it helps, when the debug is open, the wheels never have a speed higher than 5 km/hr

Force of air resistance

I imagine this is going to be a big part of the vehicles not going to excessive speed when we set the right engine torque and gear ratios :slight_smile: Will add it to the master class!

I agree, the force of aerodynamic resistance will play a tangible role only at high speeds. Suppose our super car moving with speed = 360 km / h = 100 m / s. Lets calculate Drad Force. DragForce = 2m^2 * 0.3 * 1.2kg/m^3 * (100m/s * 100m/s)*0.5 = 3600 Nutons. Letā€™s assume that at the maximum speed the engine of our super car develops a torque equal to 500Nm, 6 gear is equal to 0.7, the diff gear = 4. We find the wheel torque. WheelTorque= Engine torque * Gear * DiffGear. WheelTorque=500Nm * 0.7 * 4 = 1400 Nm. Now divide this value into the radius of the wheel to find out the frictional force that the wheels place on the road - this will be the traction force. Traction Force = WheelTorque \ WheeelRadius. Traction Force = 1400Nm / 0.34m = 4117N. We see that even with such a huge torque of the engine (500 !!!) at very high revs(~7000-8000 rpm), which is hardly possible with conventional engines, the force of the aerodynamic drag approaches the traction force. Simply put, at such a high speed(>360 km/h), the air resistance force completely compensates for the traction force, and the car will not be able to accelerate even more. There will already have to adjust the aerodynamic parameters of the car - to reduce the coefficient of aerodynamic resistance, and the cross-sectional area of the car.

Hereā€™s a good article on the wiki about aerodynamic resistance. Here you can also find the coefficients of resistance of different brands of cars and their cross-sectional areas.

new update!

I also wanted to share one development - feedback from the wheels to the engine. When drive gear and clutch is on, not only does the engine accelerate/brake the wheels, but the wheels also affect the engine, do not they? There may be several solutions, for example, to calculate the torque from the traction force, and then apply it to the engine. But the most likely simple and effective way is this. We recalculate the angular velocity of the wheels back through the transmission and compare it with the engine speed. Multiply this difference by some coefficient (clutch friction coefficient?) And subtract the resulting number from the current engine speed. If the wheels spin faster, the number will turn out to be negative and minus the minus will give a plus, that is, the wheels will start to spin the engine. If the speed of the wheels is less, they will start to brake the engine. The implementation of this issue will simulate such an effect as if the car jumps on a bump and its wheels stop touching the road and the throttle pedal is pressed so far, then the engine no longer has resistance from the road and its speed instantly soars up. You can go further. We can consider, for example, the difference in speed in the clutch, and if the difference is too great for a very long time, then the clutch breaks down(As in those videos on YouTube X)). In other words, the engine speed in my project is considered in 2 functions - 1) the function where the engine spins itself up if the throttle is pressed, and brakes if the throttle is released. 2) function with differentials and feedback between the wheels and the motor

Oh yeah, I almost forgot to say about still another plus the implementation of the feedback of the wheels and the engine - now if the car does not start with a key (the battery has sat down or the starter is broken), then it will be possible to start the engine pushing the car - just like in life =)

With the new system of wheels being separated from the mesh, is there a tutorial on how to setup a vehicle with the wheels separate? Iā€™m hoping this update may have fixed my issues, but I canā€™t find any areas in the blueprints to set the wheel mesh
I haven only been looking for ~10 minutes, but havenā€™t found anything yet

Wait, can I use something like this to know how much of the torque the engine can deliver is actually usefull? like, when the car is going at 100 km/h maintaining the speed does not require much effort from the engine, but starting from 0 on 4th gear would be almost impossible since the engine would not have enough torque to get the wheels started because of the gear ratio, wich causes stalling. I would like to implement that for both stalling and determining how fast the rpm will raise, according to the ā€œloadā€ put on the engine?

It is a variable in the setup seting, or it is not a variable yet and can make it into a variable, open the master class and go into the ā€œcreate wheel constraintā€ function. There will be a node somewhere spawning the wheel mesh before attaching it via the constraint.

Yes Yes exactly. If you make a feedback, then the car will be difficult to move on high gears. And if we admit at high speed and high gear the car will sharply turn 180 degrees, and in time did not lower the gear by 1 or 2, then the engineā€™s speed will drop sharply and it may stall. In my blueprint at the end of the function, I used the clamp node to limit the minimum and maximum engine rpm. Just remove this node, and insert there or in another place the branch - if the speed fell below the minimum, then the engine stalls.

As I wrote above, this way, when we just compare the speed of rotation in the clutch on both sides of the barricades and level them, very simple and effective. I tried it already in 2 different game engines - everything works! Concerning the calculation of resistance in force or torque. To calculate the resistance torque you need to know the traction force of all wheels. To calculate the traction, you need to know the current suspension force. This is easy if physics is implemented from scratch on the forces. But in our case on physics based on constraints, we can not calculate this accurately, only very approximately.