Game object reaction

I want to make my objects react on hit, pushing, or any other physical movement. Anyone has a good script for that?

I feel these would be helpful for you. (https://www.youtube.com/watch?v=FbMwqd9MF3c)
(https://www.codemahal.com/video/moving-an-object-with-force-in-playcanvas/)

2 Likes

If you had a physics based character than if the object has a dynamic rigid body than that should work.

1 Like

Am i using the right script? Object just passes thru other, and i did put the rigid body and collision??

var Collider = pc.createScript(‘collider’);

// initialize code called once per entity
Collider.prototype.initialize = function () {
this.entity.collision.on(‘contact’, this.oncontact, this);
};

Collider.prototype.onCollisionStart = function (result) {
if (result.other.rigidbody) {
this.entity.translate(0, 1, 0);

}

};