[SOLVED] Accessing p2.js physics objects in script

I’ve just started using the 2d physics scripts from https://playcanvas.com/project/446127/overview/p2js-integration, and I’m wondering how I access the rigid bodies made using these scripts in code. Do I access them like I would any other rigid body (e.g. this.entity.rigidbody)?

For the p2.js integration, you’d do:


From that, I assume accessing the collision would be done via this.entity.script.p2Circle/Box.<property/function>?

Yup, exactly. :slight_smile:

1 Like

I am getting error while clicking on ‘parse’ button of p2-integration.js file.

Any idea how to fix that.
Project is here- https://playcanvas.com/project/584249/overview/2dtrial

I managed to get it to parse by removing the placeholders for vec2 attribute (@vaios bug in the parser?)

placeholder: ['X', 'Y']

Full script here: https://playcanvas.com/editor/scene/659131

Its working now.
Thank you very much :slight_smile:

Is it possible to add custom collision shape in playcanvas (as in here ConvexShape).