Setting velocity to zero

I want to set my current velocity to zero on event trigger. I am using p2.js integration so rigidBody won’t work. Please help:

Hi @mortal_phoenix,

To set a p2.js body to act as a trigger set the Sensor option to true:

From there you can use the following method to listen to contact events and filter your trigger e.g. with its name:

// --- this should be added to a script attached to your p2 World entity"beginContact",function(evt){

    if( === 'Trigger' || === 'Trigger'){
        // set velocity to zero

}, this);

This tutorial explains, among other things, how p2 physics work:

1 Like