How to add gravity to a Pawn?

Hi,
I would like to add gravity and physics to a Pawn, anybody know how ?

Add Movement Component it adds physics to actor

objects inheriting from defaultPawn or Character can have movementcomponents, but if you want to have movement on a regular Pawn type, you need to make your own movement component, or just put the movement code in the event blueprint.

gravity and friction can be simulated with some simple math:

gravity is a type of acceleration, which means its a variable that adjusts velocity every tick.

for gravity, you can make a vector of (0,0,-1) then multiply it by a float that you can call “gravity”, then add that result to your pawns velocity every tick. if the pawns velocity becomes greater than terminal velocity, don’t add anything.

for friction, you can multiply your velocity by a friction coefficient, which is just a float with a value of less than 1.
0.9 would be slippery like ice, 0.2 would stop things quickly.

doing this in C++ would be much more efficient than blueprints, especially if you want an army of pawns on screen, but for small games with few moving parts, it probably wont make a difference.

2 Likes

Hey Scott,

I like your idea of simulating gravity via maths (as I’m working with just a pawn) but I’m really struggling to get this down in blueprint form. Could you help me out please? The logic of it makes a lot of sense but I’ve spent hours and hours trying to make sense of this in blueprint and nothing’s working thus far.

To give you some context I’ve been following this hover car blueprint tutorial [Unreal Engine 4.7+] Hover Vehicle Blueprint Tutorial - YouTube. It’s been going great but now when my car shoots off a ramp with the throttle held it continues on climbing at the same heading and at the same speed. If I release the throttle it slowly drifts back down to the ground with the nose of the car still pointing in the air.

In that scenario I need gravity to bring the car back down to earth irrespective of whether the throttle is still held or not.

I appreciate this is an older thread now but there’s really very little on the web regarding gravity use on pawns and the above is the closest I’ve come to a clear cut answer.

Any help would be really appreciated!!
Thanks.

What kind of movement component? The only one I see suitable for this is Floating Pawn Movement Component which the tooltip says it doesn’t have gravity.

I’ve been having the same issues with this too. The physics properties when it comes to moving actors and pawns is not intuitive or well documented when making custom pawns. So I’ve been having to do a lot of reverse engineering myself trying to emulate how a tracked vehicle behaves in a physics environment.

Hi Scott! Could you please provide an example on this in C++?

Make the Skeletal mesh the root component and enable gravity on it.

If only. Yeah I have been googling for the “Add -Z to Velocity, Clamping at Terminal Velocity” Function to throw into my C++ custom movement component. I will share it here if I find it.

Just set physics enabled for the capsule collision it has to be the root component for this to work, then just constrain the physics position to no rotation in the x, y and z axis. This ins’t perfect but seems to work perfectly fine. If there are any collision issues just create a new collision channel for the capsule to control what overlaps etc.

How do you constrain the physics postition?