[Question] Custom gravity with wheeled vehicle?

Hi,

I have been experimenting with vehicles and I am pleased that it is now possible to drive upside down, because in UDK the engine always stalled when the car reached a certain slope angle.

However I stumpled upon two problems:

  1. The tires lose all friction when I set DefaultGravityZ to 0. I used a radial force actor to pull the car onto a planetoid but it does not move at all while the tires keep spinning at full speed (they definitly have contact with the floor). The stronger I set gravity the more the tires grip, however that defeats the purpose of having a planetoid in the first place, because the car either falls off at the bottom or is pressed down so hard on the top that the suspension cannot work.

  2. I have found no possiblity to manually apply a directional force to the vehicle. The constant direction volumes from UDK do not seem to exist and all tries to apply forces from code failed. Using AddForce of the VehiclePawn’s Mesh does not do anything and GetMesh of the VehicleMovementComponent is protected which makes me assume it should not be tempered with. No other component seems to have the AddForce method.

I have also not succeeded in finding a way to derive my own force actor or component since the necessary methods do not seem to be included in the header files for me to override and the lack of documentation on that topic is not helping either.

Even if I were to find a solution to the AddForce problem I imagine it would still be affected by the first issue.

greetings,
Pascal

Moderator Only Post:

I imagine #1 is “Works as Implemented” ?

hey, I can see that there is a comment from Paul Oliver, but I cannot see what it is :frowning:

Calling AddForce on the SkeletalMeshComponent ‘Mesh’ in WheeledVehicle certainly should apply a force to the vehicle body. Note that right now the vehicle code does make assumptions about gravity in order to balance the car, so you may need some extra tweaking in order to make it work properly with your very different gravities.

Hi,

I got it working. I simply forgot to multiply the force by the vehicle’s mass, which is why it did not look as if the force was being applied.

However the “sliding error” still exists: If I have no gravityZ the vehicle has no friction, however it works perfectly if I set/leave the gravity to/at -980 and cancel it out with a force of (0,0,980)*mass I can use extra gravity forces just fine.

I took a look at the link posted by Luke Parkes-Haskell and from what I can see PhysX seems to allow for gravity vectors different than up and even has parameters specifically named gravityDirection. Also, apart from the weird necessity to cancel gravity manually out everything works quite well.

I read that the vehicle system is still undergoing heavy changes, so it would be cool to have it support non-standard gravity.

Thanks and greetings,
Pascal

Id just like to chime in here, even under flat gravity a vehicle driving through a loop (like a rollercoaster loop) will gather enough inertia that at the peak of the loop (being upside down) the suspension will actually start to contract (depending on spring stiffness and damper). There is various reasons for this, downforce and centrifugal effect, gaining too much speed will cause the vehicle to dig in because there is more force than the vehicle is designed to deal with under gravity (assuming soft suspension).

I guess what Im trying to say is that a wheeled vehicle may not be a car, it might be a shopping trolly or a mine cart, it may have complex aerodynamics or it may not, it might be powered or not, or it could be polyurethane wheels on grass. Basically Id like as little assumptions made as possible, I know not everything can be entirely generic but if engine were a component of a car then we could have a free rolling car which could be used as a skateboard for instance and if we put a thruster on the back we have a jet board.

Now with that said an engine has quite abit of mass but its not always the center of mass for a powered vehicle, in the case of a speed boat Id say yes the engine is but in a car its quite possible that the aerodynamics level the downforce and other components add weight distribution so the true center of mass doesnt reside at the engine or the center of the chassis but somewhere in between. Youre probably thinking omg this is all too much we arnt making simulators but this is very basic physics and there is already much more complex stuff going on with lateral slip, without proper gravity and centers of mass the simplest things get ruined much like turning wheels collisions not replicating.

Thanks.

Hi Pascal,

The vehicles in UE4 are driven using the PhysX vehicle setup (https://developer.nvidia.com/sites/default/files/akamai/physx/Docs/Vehicles.html), and I’d hazard a guess that the implementation somewhere along the line will assume that Z is down - this is manifesting itself in 1) where it appears to be only taking Gravity in Z into account, and not forces that would otherwise be applying it to a surface.

In the case of 2), AddForce() and AddForceAtPosition() should be able to affect the vehicle via a primitive component (the mesh component?). If you’re unable to get this to work, I would consider that this may be a bug.

Unfortunately this probably isn’t the answer you were hoping for, but I would consider that the unique requirement you have for your vehicles may mean you should instead be considering building your own setup for driving them rather than relying on the default PhysX implementation.

On the other hand, the vehicle systems are also still fairly ‘in development’ and have changed significantly between builds, so it’s possibly that some functionality you want hasn’t been exposed yet (and other functionality may be subject to change).