Gamebop / physics

Physics components for PlayCanvas
https://gamebop.github.io/docs/
3 stars 1 forks source link

Allow to stop isometry auto-update #54

Closed LeXXik closed 5 months ago

LeXXik commented 5 months ago

Fixes: #41

This PR adds an ability to stop entity <> body automatic synchronization.

entity.addComponent('body', {
    motionType: MOTION_TYPE_KINEMATIC,
    objectLayer: OBJ_LAYER_MOVING,
    autoUpdateIsometry: false
});

// then on frame update, or when needed, move both - body and entity:
// entity
entity.setPosition(newPosition);
// and body, using one of the movement methods, e.g.:
entity.body.teleport(newPosition);

If set to false, the backend will no longer tell frontend where the dynamic body is, and frontend will not tell backend where a kinematic body is. No effect on static bodies (they don't move anyway).

This is useful when you have many kinematic objects, but rarely change their position/rotation. Then no need to update their isometry every frame.