[SOLVED] What's the easiest solution for AIO movement?

Hello, what would be the easiest solution to have an all-in-one movement for all needs: Walking on level surfaces, uphills, downhills, stairs and so on.

What has been tried and discovered
Movement using forces:

  • Gravity significantly changes movement, with standard -9.8 gravity, stairs, hills and other obstacles work perfectly, but when jumping/or the player falling in the air, other solutions are needed.
    Solution 1: When the player has no contact with other rigidbodies, setting the gravity to -40 to create a faster/more realistic fall effect.
    Disadvantages: When the player starts to touch the rigidbody again, the movement is slowed down for a while, the stairs do not work as they should (collision detection instability, start, end, start, end) because the gravity is too high and the movement force is too low.
    Solution 2: The same gravity is maintained, when the player is not in contact with the rigidbody, a downward force is given.
    Disadvantages: Instability, “gravity” is different between jumping and free falling.

Movement using teleport:

  • Strong -40 gravity perfectly copes with falling, jumping, does not take into account obstacles, stairs and uphills, etc. works perfectly, but when the player is teleported (Walking) you may encounter strangeness, since gravity is ignored.
    Falling without walking works perfectly, only by pressing any movement key, sometimes you can “walk in the air” even though the force of gravity is high.
    I haven’t come up with a single possible solution, do you have any ideas? For some reason I want to stick to moving with teleport, I am looking for a solution that does not take into account obstacles and is suitable for practically everything, the biggest problem is “walking in the air”.

Thanks for any information or examples

I was playing around with a 3D platformer that I’ve not had a chance to go back to yet. Maybe there’s something there that could help?

It uses forces:


Now that’s a smooth experience, although it fails to pass the stair test, recently an idea came into my head that I decided to try, why not just use both movement methods using the advantages of each, and what can I say, it works as expected!

  • Stair test passed
  • Uphill/downhill test passed, same movement speed
  • Jumping, falling - also no problem, no slowdown after jump

How does it work?

PlayerAnimationHandler.prototype.onContact = function(result) {
    this.player.moveBy = "Teleport";
    console.log('Should move by teleport');

PlayerAnimationHandler.prototype.onCollisionEnd = function(result) {
    this.player.moveBy = "Force";
        console.log('Should move by forces');

There are a few things to be aware of, both methods must be used with

var forward = camera.forward;
var right = camera.right;

Also you can’t use rigidbody.teleport together with rotation, instead you need to setLocalEulerAngles for the entity that has the player model

It is also very important to match the “speeds” between different movement methods, I hope this will help someone in the future