Back to Content
The Physics Engine in CopperCube
CopperCube includes a physics engine for moving objects and colliding stuff automatically. This section gives a small overview on how it works.
The built-in Collision and Response System
By default, CopperCube has enabled a simple and very fast collision and response system. It works on all targets with very high performance, even on slower targets like Flash, Android and WebGL.
With it, characters can move through the 3D world, move up stairs, and collide with walls. You only need to add a Collide when moved behavior to the object, and everything then works automatically.
However, this system also has shortcomings:
- Two moving objects won't collide very well with each other, and might go through each other.
- If you have some very degenerated 3D geometry in your world, there might be places where your objects might get stuck.
If you want more advanced features for the physics in your app, you can use a 'real' physics engine in CopperCube as well:
The built-in Physics Engine
Alternatively, CopperCube also has a built-in 'real' physics engine: Objects will collide with each other, influence each other and similar, just like in the real world.
To make this work, you need to enable the physics engine in the publishing settings dialog. This only is supported for some publishing targets, such as Windows .exe and Mac OS X .apps.
Use the Collide when moved behavior for characters moving through the world as before, and add the Object moved by physics engine behavior to objects which should be moved in the 3D world, like boxes and barrels, for example.
The system works nicely, but there are still a few limitations:
- 3D meshes should not be moved manually when using the physics engine. The engine will not be able to handle this. Instead, use the Object moved by physics engine behavior for passively moved objects and the Collide when moved behavior for actively moved objects.
- If you move a part of the static collision geometry, and want the physics engine to respect that, simply run the JavaScript command ccbUpdatePhysicsGeometry() afterwards. You can do this with a 'Execute JavaScript' action.
- As the built-in collision response system, the physics engine will get slower the more objects, and the move complicated the static 3D world is, so be sure to design your world wisely.