[Solved]characterControl movement speed

Hi, I have altered the example of the TestWalkingCharacter class, but for my world (tiles of 1 World Unit) the character is moving way to fast. I know I have to do something to the walkdirection, but I just can’t figure out what :s

I already tried setting the camera to a lower movement speed… but that didn’t do anything :frowning:

As you can see in the code I altered it so when the camera moves the model moves with it. Somebody can tell how I can slow the player down?

[java]public void simpleUpdatePlayer(float tpf) {

Vector3f camLeft = gamePointer.getCamera().getLeft().clone().multLocal(0.2f);

viewDir.setX(gamePointer.getCamera().getDirection().getX());

viewDir.setZ(gamePointer.getCamera().getDirection().getZ());

camLeft.y = 0;

walkDirection.set(0, 0, 0);

if (left) {

walkDirection.addLocal(camLeft);

}

if (right) {

walkDirection.addLocal(camLeft.negate());

}

if (up) {

walkDirection.addLocal(character.getViewDirection().setY(0).normalize());

}

if (down) {

walkDirection.addLocal(character.getViewDirection().setY(0).negate().normalize());

}

if (!character.onGround()) {

airTime = airTime + tpf;

} else {

airTime = 0;

}

if (walkDirection.length() == 0) {

if (!“Stand”.equals(animationChannel.getAnimationName())) {

animationChannel.setAnim(“Stand”, 1f);

}

} else {

character.setViewDirection(walkDirection);

if (airTime > .3f) {

if (!“Stand”.equals(animationChannel.getAnimationName())) {

animationChannel.setAnim(“Stand”);

}

} else if (!“Walkcycle”.equals(animationChannel.getAnimationName())) {

animationChannel.setAnim(“Walkcycle”, 0.7f);

ClientHandler.sendAnimMessage(“Walkcycle”);

}

}

character.setWalkDirection(walkDirection);//De snelheid en de richting waar het charachter naartoe gaat

gamePointer.getCamera().setLocation(character.getPhysicsLocation()); //camera volgt het character

character.setViewDirection(viewDir); //Character draait mee met de camera

}[/java]

For bullet 1 unit = 1 m, you have to adapt gravity and forces accordingly when you want to scale to anything else. The character is a special case as its simulation is dependent on the update frequency (60 fps).

Ok found it, I had found this before but the order of the methods was a bit wrong, so for the player to move up and back at a good speed I had to change from



this:

[java]if (up) {

walkDirection.addLocal(character.getViewDirection().setY(0).normalize());

}[/java]



to this:

[java]if (up) {

walkDirection.addLocal(character.getViewDirection().setY(0).normalize().multLocal(0.2f);

}[/java]





Now the player keeps moving even when the camera is on top. I had added the multLocal before but in the wrong position :frowning: