GetVelocity returning really small values

Newbie question here. (I’ve been starting to learn UE4 for a little less than a week.)
I’ve got a simple box, set up as a pawn, that I drive / move around my scene using basic keyboard input. Forward / backward, turn left and right. In the blueprint, I can grab and print the vector from GetActorForwardVector and it shows X,Y and Z values as I would expect. But if I do the same with GetVelocity, I get minute values that barely change. If I drive my box up and over something else in the scene and it begins to fall, then the GetVelocity Z value grows as I’d expect, but just driving around on a flat surface results in values I just don’t understand.

What I’m trying to do is just get the forward velocity of the thing I’m “pushing” around in the scene (ie I don’t have forces or motors - I’m just using AddActorLocalOffset to move the thing around and I want to grab it’s speed).

You’re simulating physics (the pawn is affected by gravity) but by Adding Actor Local Offset you’re not interacting with physics. It’s closer to teleporting every frame and it makes the velocity reading inaccurate. When the pawn finally starts falling, the physics simulation kicks in properly and the reading is correct.

In short, this is not the kind of movement you’d use in a setup like this. Adding Actor Offset and physical simulation will not produce velocity.

You have options:

  • for pure physical interaction:
    – ensure the simulated component is the root of the actor (a static mesh / collision)
    – ensure it simulates physics and is affected by gravity
    Add Force instead of Add Actor Local Offset (this should be World Offset, as local makes little sense but it accidently works ok as we’re not attached to anything)

or

  • take advantage of the Floating Pawn Movement component
    – add the Floating Pawn Movement component to the actor (comes with extra features)
    – ensure the simulated component is the root of the actor (a static mesh / collision)
    – ensure the component at the root simulates physics and is affected by gravity
    – use the Add Movement Input node to move it

You can then read velocity from the Floating Pawn Movement component or from the actor as you do. You will even get velocity from both without simulating physics as the component will fake it. But you need simulation for gravity.

As a bonus the abovementioned component comes with extras:

image

And the way it handles collision is more reliable.

Thanks for the tips. I did wonder yesterday if it was the first problem you mentioned and I did try an AddForce method but no matter how much force I add in the X direction, it doesn’t move. Meaning either I have it hooked up wrong or the force value needs to be in millions of units?
This is what I have for AddForce:

I then stripped that out and added a FloatingPawnMovement instead. The AddMovement node did work (although in world space, not local to my model) but GetVelocity still returned basically zero.

I’m obviously missing one nugget of information here to complete my knowledge on this but I can’t quite figure it out. I’ve been circling the answer for over a day now - I know I’m close.

Also my test box has now become a tank model I built a while back. Hence the structure and sockets. The intention here is NOT to simulate a tank by the way. :slight_smile:

Accel Change False ignores mass. The tank is 3t, we need more oooomph. Tick Accel Change to test it out. If it works, disable it and crank up the applied force by a couple of orders of magnitude (at least!)

Moving a 3t box with physics:

Image from Gyazo

But that’s not how tanks usually move. Force is applied at the centre of the mesh hence the top-heavy behaviour. You can Apply Force at Location but it’s fiddly.

If the collision of the root component is a boxy box (as above), it may be getting stuck - check here for things you could tweak:

You can transform direction both ways with:

image


but GetVelocity still returned basically zero.

For a fake tank that moves somewhat realistically:

  • the mesh simulates physics and gravity
  • the movement component does not care about mass but mass will affect other components the actor interacts with

Also, if you want your mind blown:

1 Like

Ok, upping the force and ticking ‘Accel Change’ worked - and did exactly what you’d expect - it caught the edge of the tank collision volume and rolled it up on its side, but I did get a velocity :smiley:
So I went with the Floating pawn movement instead and things are going the right way now. Excuse my ignorance (like I said - only in week 1 of UE) but the yellow node in your diagram that takes the floating pawn movement and pipes it to the vector length - what node is that?

It’s vector * float.

Ah - no - the other one. I figured it out - it’s getvelocity, dragged from the reference to the floating pawn movement.
Brilliant - I have a “box tank” moving around now - this has been so helpful. I added a transform and now my boxtank is moving around as I would expect and I’m getting velocity feedback from it.
Thanks so much !!

1 Like

In case you’re curious, I needed this so I can make the wheels on the tank spin as a result of the velocity. Rather than being a complex physics-driven object, it needs to be a ‘semi-dumb’ actor that spins wheels based on whatever is moving it (in this case player input). So no suspension, no motors etc, but a general-purpose blueprint that can be used to drive the wheels on any other ‘dumb’ vehicles I have in the scene.

1 Like

Consider my mind BLOWN! Will definitely be looking through this. I have been looking for a way to simulate mechanical parts like this!