Movement with real physics

Hi all, I’ve been trying to make a movement script with real physics with bad results and I wonder if someone made something similar. My main problem is that I don’t understand how to configure it to make my character inmune to X and Z rotations, be able to jump and not have a really slippery floor. When I solve one of the problems I get another one…

Did any of you manage to do something realistic? Using physics I mean.


1 Like

The first person movement tutorial deals with a lot of these problems:

Yep but still not jumping :confused:

I forgot to say that I try to set real size and mass in my character

There are several ways to go about this.

  • The linear damping set on the rigid body is for all axes. If you want to allow for jumping (the Y axis), you need to set this back to 0 and apply the damping on the X and Z axes yourself in the update.
  • Instead of using forces to move the player, set the velocities of the rigid body directly (ie. On key down, give the rigidbody a velocity. On key up, set the velocity to 0).
  • Not use the physics at all and simulate the player movement yourself

Sounds logical, I will try that. Thanks for the help!

Actually, this should stop any movement right?


Because it is not stopping anything :S And I am calling that from the rigid object I am moving.

linearVelocity is a property so you will need to do something like this unfortunately:

var linearVelocity = this.entity.rigidbody.linearVelocity;
linearVelocity.set(0, 0, 0);
this.entity.rigidbody.linearVelocity = linearVelocity;