So I’ve had no issues creating an advanced vehicle however, how does one go about allowing a vehicle to land upside down without the vehicle immediately flipping upright again. Additionally, (after adjusting wheel diameter & width perfectly) while using spheres for collision, hitting the sides of the tires produces unwanted results. It often sends the car flying/flipping into the air. Is there any content or documentation out there that might help me with this? I’ve followed the documentation on creating/rigging my vehicle(s) with success. I am just not entirely certain about this particular issue.
The first thing that I do search for others having my issue but it seems that several others have had this issue and the thread ends up dieing without any resolution or clue as to what might be the problem. I want to make it so that my vehicle(s) can drive upside down and from what I can tell, “Raycasting” seems to be the potential culprit. Am I right about this?
Here’s a video that demonstrates my issue:
At this point, I am willing to pay someone for help. I’m at a loss, so far.
PhysiX vehicle does ray cast only downwards, so your suspension won’t react to vehicle being flipped. A lot of PhysiX vehicle have much bigger mass and very low center of gravity for stability, which again can be an issue and this is what makes them flip back to wheel easily.
I assume that you are targeting arcade style of gameplay so my suggestion would be to make your own vehicle component. It’s not hard, I did it myself with just blueprints for 10 wheeled vehicle with all wheels driving (check signature).
Two parts that you need is suspension and a bit of custom friction physics. I can explain how I’ve build them in my case and can tell you what works and what might not work or requires some C++ coding.
@BoredEngineer](https://forums.unrealengine.com/member.php?12960-BoredEngineer) - I would be more than happy to hear how do you created your own vehicle. Another thing to ask though - is it possible to always keep raycasting looking down (without locking on the local rotation) or would that smudge up the physics?
Yes it’s possible, but why would you want to do it? The idea in general is to simulate a simple spring and dumper as your suspension. If your spring is perpendicular to forward vector of vehicle it will push it up, if it’s at 45 degrees it will push it up and forward or backward.
If you want your vehicle to drive up side down and have suspension working both ways you need a double spring and dumper setup for each wheel. Something like this:
Each spring produces the force, proportional to how much spring is contracted:
TotalSuspensionForce = SpringForce * (TargetLength - CurrentLength) + DampingForce * (TargetVelocity - CurrentVelocity)
TargetLength - is a full length of spring without any pressure applied to it.
CurrentLength - is the length of the spring when wheel collides with something. To find a CurrentLength you do a RayCheck or SphereCheck from the root of the spring to the end of the spring (TargetLength) + radius of your wheel. RayCheck or SphereCheck will tell you a point of where “wheel” would be collide with something and this is where it will be in the world, at this point spring will be either extended or contracted. You have to decide if you want your spring to only push or it should pull as well, like if axle of the wheel is rigidly attached to the end of the spring or it only “collides” against the end of the spring.
If your wheel is not rigidly attached then formula would be like this:
SpringCoefficient = Clamp((TargetLength - CurrentLength)/TargetLength, 0, 1)
in case of spring fully extended to TargetLength or more coefficient will be 0
TotalSuspensionForce = SpringForce * SpringCoefficient + DampingForce * (TargetVelocity - CurrentVelocity)
SpringForce and DampingForce are constants that you need to find yourself. SpringForce is necessary to support weight of the vehicle pushing on spring. DampingForce is necessary to stop spring from osculating too much.
TargetVelocity is normally 0 unless you want your damper to work as velocity drive - constantly push or pull on spring. CurrentVelocity you need to calculate simply by:
(CurrentLength - CurrentLengthFromPreviousFrame) / deltaTime
Resulting TotalSuspensionForce is what you apply as AddForceAtLocation to the root body of your vehicle, position of application can be at the point of wheel collision or root of your spring, you need to try and see what works better for you.
What I’ve described works for a regular single spring per suspension system. As you have two spring systems, first you would need to run RayCheck or SphereCheck for both springs, decide where the wheel position will be, which tells you which of the springs will be contracted so you calculate TotalSuspensionForce just on that spring. The way you can decide it is by projecting velocity or acceleration of the vehicle on each spring vector and choose one where projection is higher. So when you drive on the ground, sum of vehicle forward acceleration and gravity will project positively on bottom suspension and negatively on top. When vehicle jumps and hits the ceiling than projection will be positive on top suspension.
Hi Xonos … Vijaysarathi Here … i have recently encountered the same issue which you are discussing here while i was setting up the the vehicle and i guess there’s no bug or anything like that from epic side as far as i know but the same issue got fixed for me after few workaround and experiments and found out that you have to keep the collision response disabled under the vehicle collision section on physics tab… i hope this helps … and if it gets fixed… you could buy me coffee or get me a ticket to epic games…