Hello, I’m try to change size of the collision object via AMMO code. but I can’t find way to do so.
https://playcanvas.com/project/1025434/overview/ammocollisiontest
this is my project that I’m trying to do, to add a collision to a object but using Ammo, for experimental purpose.
So I somehow managed to add collision to location of the box, but its size is being issue.(I think) The collision is there, I can detect it by raycast when shooting ray on center of the box. But it’s so tiny that I cannot stand on it, or detect the collision smoothly.
What do you think the problem is? I tried changing halfextents, localScale of RigidBody. But nothing seems to work.
var CubeColTest = pc.createScript('cubeColTest');
// initialize code called once per entity
CubeColTest.prototype.initialize = function() {
var dynamicsWorld = this.app.systems.rigidbody.dynamicsWorld;
var ammoHalfExtents = new Ammo.btVector3();
ammoHalfExtents.setValue(2,2,2);
const shape = new Ammo.btBoxShape(ammoHalfExtents);
const rbodyconsinfo = new Ammo.btRigidBodyConstructionInfo (0, Ammo.btDefaultMotionState(),shape);
const newTrans = new Ammo.btVector3 ();
newTrans.setX(this.entity.getLocalPosition().x);
newTrans.setY(this.entity.getLocalPosition().y);
newTrans.setZ(this.entity.getLocalPosition().z);
const transformDoIt = new Ammo.btTransform();
transformDoIt.setOrigin(newTrans);
const rbody = new Ammo.btRigidBody (rbodyconsinfo);
rbody.setWorldTransform (transformDoIt);
// console.log(shape.btBoxShape());
rbody.setCollisionShape (shape);
dynamicsWorld.addRigidBody(rbody);
};
// update cod