Collision Reaction
This is an archived page! This page is very old and the content is not up to date. Not everything (if any) which is written here will be in the final game! |
Module Pwner: Patrick Boenzli (patrick [at] orxonox [dot] net)
Overview
You can find the whole source in this directory, the main modules are:
- Collision Tube - collects all collision information and stores them
- Collision Event - each obb intersecting with an other obb fires such an event, contained in an Collision object
- Collision - defined as the event of two objects intersecting, contain CollisionEvents
- Collision Filter - looks if two objects are listening for collisions between them
- Collision Reaction Engine - controlling the collision reactions and checking out the Collisions
Coding Examples
Subscribing to a CollisionReaction
All WorldEntities are able to subscribe to CollisionReactions. These object will only react to objects specified in this subscription and will only react with an action choosen in this subscription. Example:
this->subscribeReaction(CoRe::CREngine::CR_OBJECT_DAMAGE, Projectile::staticClassID());
You can find this function prototype here. This registers the object to a damage reaction to all Projectile classes (and subclassses) (BTW: this is the default subscriptoin of all WorldEntities).
Object Damage
Object damage is evaluated with the CRObjectDamage CollisionReaction object. Each WorldEntity has got a float damage that can be accessed via void setDamage(float damage) and float getDamage(). The damage to another object is evaluated with this damage variable. Here is a short example:
this->setDamage(100.0f); this->subscribeReaction(CoRe::CREngine::CR_OBJECT_DAMAGE, Playable::staticClassID());
This sets the damage caused by this object to all other objects to 100.0f (units). All Playables will recieve this damage by collision but only if they are subscribed for this collision reaction. If the Playable itself has not subscribed for this collision reaction it won't be harmed. This subscription specifies which other objects may damage this object