Pyro / Collision System

Pyro has its own lightweight collision system.

It uses the following classes:

CollisionMonitor2D
CollisionState
CollisionAudio


The CollisionMonitor

The CollisionMonitor or CollisionMonitor2D defines what objects or group of objects are detected on collision.

To setup the CollisionMonitor2D you must first create a GameObject and add the CollisionMonitor2D component to it.

For example:



After setting up the CollisionMonitor2D you can create the sprites.


The CollisionSate

To have the CollisionMonitor2D detect collisions of the sprites you must add a CollisionState component to them.



The key part is to have the sprites that need collision detection match the groups set by the CollisionMonitor2D.

So if you have sprite A and B and the sprite A Group variable is named player and sprite B the Group variable is named Enemy the collision will be detected when these are defined as above with the Collision Monitor example.

The CollisionState depends on Collider 2D components.

A Box Collider 2D will be added automatically to the GameObject when a collider is missing.

See CollisionState for information about the CollisionState settings or variables.


Collision Sound Effects

The CollisionAudio component determines which sound effects are played depending on the material set (not to be confused with Unity materials).

Think with material as steel, glas or wood for example that determines the sound on impact.

To setup the CollisionAudio you must first create a GameObject and add the CollisionAudio component to it.

There is a default engine that can be added to your scene that has most of this setup.

Use the Unity menu and go to: GameObject > Playniax > Prototyping > Engines > Pyro

Here is an example: