itch.io is community of indie game creators and players

Devlogs

3DObject and cannon-es.js Construct 3D and 3D collision and physics

Construct 3 3DObject Plugin
A browser asset pack made in HTML5

A simple example integrating 3DObject with cannon-es.js (javascript 3D physics library.)

Since C3 does not have a 3D physics/collision system, we can leverage an external library to implement it.

The example includes joining a 3DObject and a cannon body together through a new 3DObject scripting interface:

setCannonBody(body, setRotation)
  - body: a reference to a cannon body
  - setRotation: boolean

If setRotation is true, the 3DObject rotates with the rotation of the cannon body.
The 3DObject will follow the cannon body's x,y,z location and rotation. No other C3 events are required, the location and rotation are set for the 3DObject every tick.

The example also includes setting a 3DObject position and cannon body position based on a C3 sprite orbiting a point (it does not set the rotation of the cannon body, so collision may be a little off. I leave this an exercise for the reader.)

The cannon-es.js library is pretty nice and very comprehensive. It can also do things like call functions on collision (addListener('collision', ...) ), etc. This can be integrated with C3 through JS scripting

Currently, I don't plan on working on a cannon-es.js plug-in/behavior for C3, however, I am very willing to help with any 3DObject integration with such a plug-in in case another developer creates one.

https://github.com/pmndrs/cannon-es

Files

  • 3DObjectCannon-1-0-0.c3p 857 kB
    Apr 05, 2022
  • 3DObject-2-23-0.c3addon 55 kB
    Apr 05, 2022
Download Construct 3 3DObject Plugin
Read comments (13)