ammo.js icon indicating copy to clipboard operation
ammo.js copied to clipboard

Getting btKinematicCharacterController to work in Ammo.js

Open MackeyK24 opened this issue 6 years ago • 3 comments

I think the last issue was closed and btKinematicCharacterController was supposed to work...

Can you please show me how to use in btKinematicCharacterController in Ammo.js

I tried attaching to the the collision shape and it looks like i t works ... but i got no movement or jumping if i call jump or setWalkDirection.

Here is how i am attaching the chracter controller using babylon.js collision shape:


            const worldMin:any = Ammo.btVector3(-1000,-1000,-1000);
            const worldMax:any = Ammo.btVector3(1000,1000,1000);
            this.m_overlappingPairCache = new Ammo.btAxisSweep3(worldMin, worldMax);
            console.log(this.m_overlappingPairCache);

            const collisionShape:any = this._abstractMesh.physicsImpostor.physicsBody.getCollisionShape();
            console.log(collisionShape);
            const startTransform:any = new Ammo.btTransform();
            console.log(startTransform);
            startTransform.setIdentity();
            startTransform.setOrigin(new Ammo.btVector3(0.0, 0.0, 0.0));

            this.m_ghostObject = new Ammo.btPairCachingGhostObject();
            this.m_ghostObject.setWorldTransform(startTransform);
            this.m_overlappingPairCache.getOverlappingPairCache().setInternalGhostPairCallback(new Ammo.btGhostPairCallback());
            this.m_ghostObject.setCollisionShape(collisionShape);
            this.m_ghostObject.setCollisionFlags(BABYLON.CollisionFlags.CF_CHARACTER_OBJECT);
            console.log(this.m_ghostObject);

            const stepHeight:number = 0.35;
            this.m_character = new Ammo.btKinematicCharacterController(this.m_ghostObject, collisionShape, stepHeight);
            console.log(this.m_character);
            (<any>window).player = this.m_character;
            console.warn("player check");
            console.log((<any>window).player);


Now errors... just does not move by me simply calling setWalkDirection... Am i support to tick the character controller some how or what ???

Yo @kripken ... Please help a brotha out :)

MackeyK24 avatar May 27 '19 05:05 MackeyK24

Sorry, I actually don't know the Bullet API well myself. I just port it...

kripken avatar May 28 '19 19:05 kripken

I figured it out ... but we need the get getOverlappingPairCache function added to ammo. Idl for both the btBroadfaceInterface and btAxisSweep3

MackeyK24 avatar May 28 '19 23:05 MackeyK24

I figured it out ... but we need the get getOverlappingPairCache function added to ammo. Idl for both the btBroadfaceInterface and btAxisSweep3

Do you mind spilling the beans on how you got it working? Would be a lot of help for me

spikethea avatar Aug 05 '20 12:08 spikethea