Physics movement velocity keeps increasing despite colliding with floor and not moving

I am working on creating my own movementcomponent with blueprints (i just wanna learn how, i don’t wanna use the character controller for different reasons)

There isn’t many guides, i only found a single one for ue4, but some stuff is off

In the video i’ve narrowed down the problem that, getting the physics velocity, adding to it, and setting it again, for whatever reason completely messes up the velocity numbers.

Even if i simply get it, add 0, and set it again, the Z component still slowly increases until it phases through the floor. You can see the capsule keeping it above ground but the gravity still wins in the end. I have no idea how to fix this. I can’t find any answers anywhere

Hey @STANN_co!

If you don’t have any logic to check if your capsule is grounded, there is nothing preventing it from continuing to increase velocity downward infinitely. You are likely going to want a downward ray cast to check if there is anything underneath the character which in turn would trigger a bool and/or event that stops this process whenever you are on solid ground and resets your downward velocity back to zero.

Good luck on creating your character!

Not directly related to the very issue at hand but do consider:

image


On topic: from my experience with physics, Set Linear Velocity can be unruly - and it will mess up collision at times. The example demonstrates what I mean rather well. The tooltip of that node is subtle but the actual results will ruin your day. It should only be used to override physics where there is no other way to achieve what you want.

Is there a reason why you cannot Add Force instead and constraint a rotation axis so you do not need to forcefully set rotation every frame FixedTick?

1 Like

Kind of hard to advise without knowing what sort of behaviour is really needed, but I’d start it like so:

The pawn

  • locking rotation constraints prevents us from tipping over, no need to reset rotation every frame
  • the Inertia Tensor Scale may be VERY important here - depends on the desired behaviour. Without it, the pawn will be too easily affected by external forces.

Inertia Tensor Scale set to 1 while moving forward only:

Inertia Tensor Scale set to 10:

The component:

Note this is using torque - not rotation, it’s quite physical and the reason why we needed angular dampening cranked up so high. And you do not want to Set Linear Velocity unless there is absolutely no other way to control the behaviour.

This is just some pseduoscript, really. Technically, there may be nothing wrong with having controls inside the component - but that should be EI. And the primitive component root should be cached.


If the goal is to make a physically-stable pawn you have plenty of control over:

The above could be a start. If you throw in a physical material into the mix, you can get it really going.

1 Like