CharacterControl ’stutters’?

I’m using a CharacterControl to move a small box:


//Move the box’s parent node. Note that timepf = tpf

characterNode.setLocalTranslation(characterNode.getLocalTranslation().subtract(1*timepf, 0, 0));

//Move the CharacterControl to the same position



The only problem I’m facing currently is that the box kind of stutters when it moves. Its movement isn’t smooth as I expected. This happens when the Framerate is constant, and also when it isn’t.

Any advice? Thanks in advance.

EDIT: Also, when the Framerate increases, it moves much slower. Its speed halves. This is noticeable when the Framerate changes from 800 to 3000.

I’ve never used physics but I think I remember reading something here saying that you only needed to set the location on the physics control. Just don’t quote me on that.

your supposed to use setWalkDirection() on the CharacterControl to move it

I tried using setWalkDirection(), but a bigger problem came up. Look at this:

At 600 fps, to cover 10WU it took 8.6446826 seconds.

At 85 fps, to cover 10WU it took 1.3191267 seconds.

This is the code:


player.setWalkDirection(new Vector3f(10*timepf, 0, 0));


I’m baffled…

That’s because the walk direction is called every physics tick, don’t use tpf with it. It does say this in the physiscs walking wiki

Thanks for the reply.

@wezrule said:
physics ticks

Is that the same as tpf?

No. Bullet tries to run at 60 ticks per second. So the walk direction is frame rate independent already, the vector you pass it will be called on the next physics tick

1 Like

I see. I understand. Thanks for the explanation wezrule :slight_smile: