Physics character controller

Do you have a PG you can share?

Hey @Cedric hey man, I am still having trouble get my own implementation of the BABYLON.PhysicsCharacterController.

I have work on a few Character controllers, especially the btKinematicCharacterController.cpp from Ammo.js

This API for movement is so different from the Unity Character Controller move function for example. I am not sure i dunderstand what make what happen. I cant tell what is actually required to move.

I am trying to create a charactercontroller.move(velocity) but not having much luck getting the BABYLON.PhysicsCharacterController to work like Unity Character Controller.

NOTE: I had this working perfectly in Ammo.js using btKinematicCharacterController.

This is what my wrapper class will look like, so you have a heads up on how i am trying to call move and set to teleport


ZONDA.FP3D.Engine.PlayerController = class PlayerControllerClass {
    #scene = null;
    #properties = null;
    #playerTransform = null;
    #physicsCharacterController = null;

    constructor(transform, scene, properties = {})
    {
        this.#scene = scene;
        this.#properties = properties;
        this.#playerTransform = transform;

        console.log("ZONDA.FP3D.Engine.PlayerController: Constructor - BABYLON.PhysicsCharacterController initialized");
    }

    // Set the position and rotation of the player controller (TELEPORT PROPERTIES)
    set(px, py, pz, rx, ry, rz, rw)
    {
        console.log(`ZONDA.FP3D.Engine.PlayerController: SET POS(${px}, ${py}, ${pz}) ROT(${rx}, ${ry}, ${rz}, ${rw})`);
    }

    // Move the player controller by the given velocity vector (MOVEMENT VECTOR)
    move(moveVelocity)
    {
        console.log(`ZONDA.FP3D.Engine.PlayerController: MOVE VEL(${moveVelocity.x}, ${moveVelocity.y}, ${moveVelocity.z})`);
    }

    // Update the player controller (SYNCRONIZE TRANSFORM)
    fixedUpdate(fixedDeltaTime)
    {
        console.log("ZONDA.FP3D.Engine.PlayerController: Update - Physics integrated and transform synced");
    }
}

@Cedric Can methods like move and jump be built into PhysicsCharacterController as public methods for developers to use, and provide some speed configuration parameters? This can reduce the need for developers who are not very familiar with the relevant physics knowledge to use these methods relatively easily to implement their ideas. As the PhysicsCharacterController name suggests, a character should have the ability to move and jump, right?:nerd_face:

Current Character controller example show moving and jumping. It’s always possible to improve the documentation and examples. But it will never be enough methods and variables to tweak to add to a character controller.

jump, double jump, strafe, swipe, run on wall, catch rope, catch ridge, … + change state and physics properties between transition…

it’s never ending :slight_smile:

You’re absolutely right. While characters do have a wide range of behaviors, I’d still recommend using basic movement methods like walking and jumping as foundational support. This approach feels more intuitive and user-friendly than implementing a getDesiredVelocity method in a playground. At the very least, most people won’t be scratching their heads when they see this class and wonder how to use it.:monkey_face:

1 Like