Adittional Collision Attributes

It would be great if something to allow the changing of a collisions position and rotation could be added. I’ve tried making my collisions child entities or parent entities of the entity I want to move, but the results never came out to be how I wanted. As an example:


I’d like to have the collision aligned with the right side of the pointer instead of aligning with the origin of the pointer…

The usual ‘fix’ here is to make the model a child entity of the rigidbody so you can align the model how you like in relation to the physics.

Can you give a quick sketch on what you want it to look like?

Also note that if you do this, then assuming this was a hinge constraint, you would also need to apply an offset on where that constraint is so that it swings correctly.

The pale orange is where the collision is now, the black outline is where I’d like it to be.

I’ve played with this, I haven’t tried it using the joints yet, but that could fix the problem I had with doing that. Of course, because I want the rigid body to be rotated slightly, this may cause other problems with the offset.

Yeah, you would need to make the model the child of the rigidbody for this.

I also just checked the ammo.js API and it looks like you can move the pivot point with setCenterOfMassTransform on the rigidbody. This is not exposed through PlayCanvas AFAIK like the constraints so you would need access the btRigidBody via the PlayCanvas rigidbody component and use it directly.

So the code would look something like: this.entity.rigidbody.btRigidbody.setCenterOfMassTransform();?

You should be able to see examples from the ragdoll project or looking at the engine source. I believe it is this.entity.rigidbody.body.setCenterOfMassTransform and you have to pass it a Ammo.btTransform which representations rotation, position and scale local offset (I think, I haven’t actually tested this).

This is what I find in the ragdoll project that looks like what you’re talking about:

var localA = new Ammo.btTransform();

localA.setIdentity();

var orientA = this.partOrientationOffsetA;

localA.getBasis().setEulerZYX(orientA.x * pc.math.DEG_TO_RAD, orientA.y * pc.math.DEG_TO_RAD, orientA.z * pc.math.DEG_TO_RAD);
localA.setOrigin(new Ammo.btVector3(offsetA.x, offsetA.y, offsetA.z));

This is pretty much what I’m looking to do here right? Using setCenterOfMassTransform instead of setOrigin

I’ve wrote a little component for this purpose.

looks like this may be just what I need. Would I be able to take a look at the project? It’s unclear in your description as to what kind of rigid bodies you are using.

Is read access enough?

As long as I can see what kind of rigid body you use, yes. I don’t need to change anything.