Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 3 (modified by landauf, 17 years ago) (diff)

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:

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