I’ve created the component shock absorber that works like in the video below. The problem is the vehicle is bouncing like in the video.
The guy on the video fix this problem by adding some linear damping that is not what I want because the gravity force not works correctly with linear Damping.
I thought that when the raycast is touching the ground and is full extended the force that must be applied to vehicle is just the opposite of gravity force, and must increase when the raycast length is less that 100%.
You can apply that to a physics-simulating object with gravity and shouldn’t have any trouble, alternatively you can just add FVector(0.f, 0.f -980.f) to Accel before adding it to Velocity, if you want custom gravity. You will also need to tweak the values. I recommend starting with something like this:
I do my hovertanks with one downward-facing trace, and another trace that follows the velocity of the craft, and average the results. I use a rotational spring to align to the surface normal rather than using multiple traces. It’s more stable, faster, and you can control the strength of surface alignment.
Well in my case it’s because angular velocity shouldn’t be affected by the spring, and I only do a single trace.
For force, just use the ‘accel’ value and plug it straight into ‘Add Force At Position’. When doing the damping equation, you need to use ‘Get Velocity at Location’ as well and not use general velocity, and pass in the bone you’re doing the trace from.
As you can see the Force and dumping i’m submitting are too higher than yours. So how can I calculate the right force to submit?
Currently the box is stable in the air but i’ve inserted these parameters randomly
To get to 100cm specifically I’m not sure, you’d have to look up spring physics and see how the resting spring length is affected by mass / tension etc. The short answer is just keep tweaking it until it’s right.
Make sure you’re apply the Force as Acceleration (should be a bool you can pass into AddForceAtLocation), otherwise the forces required will change depending on the objects PhysX mass. Also means you don’t have to use such high values.