Planet
navi homeaboutscreenshotsdownloaddevelopmentforum

Collision Reaction

ArchivePage?

Module Pwner: Patrick Boenzli (patrick [at] orxonox [dot] net)

Overview

You can find the whole source in this directory, the main modules are:

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

Last modified 9 years ago Last modified on Sep 21, 2008, 8:57:19 PM