Hey there
I’m working on making a gun shoot and apply an impulse if it hits a Rigidbody. I found this thread with a solution from @will
https://forum.playcanvas.com/t/using-impulses-to-shoot-boxes/2038
It works quite well!.. That is until my Rigidbodies (boxes) have been turned 180 degrees by shooting at the corners. Then it’s as if they try to rotate in the opposite direction - against the bullet!
Any idea why that is?
Here’s my own code:
const impulse = new pc.Vec3().copy(this.outTo).sub(this.player.view.head.getPosition()).normalize().mulScalar(10);
const localOffset = new pc.Vec3();
const mat = rb.entity.getWorldTransform().clone();
mat.invert();
mat.transformPoint(this.outHit.point, localOffset);
rb.applyImpulse(impulse, localOffset);