Skip to content

Instantly share code, notes, and snippets.

@kcbanner
Created February 17, 2014 22:20
Show Gist options
  • Save kcbanner/9060377 to your computer and use it in GitHub Desktop.
Save kcbanner/9060377 to your computer and use it in GitHub Desktop.
void AttackComponent::onEntityCollisionEvent(IEventPtr pEvent) {
std::shared_ptr<EntityCollisionEvent> pCastEvent = std::static_pointer_cast<EntityCollisionEvent>(pEvent);
// Don't care if we collide with our selves
const RigidBody* aRigidBody = pCastEvent->getRigidBodyA();
if (aRigidBody->name == PROJECTILE_RIGID_BODY_NAME && aRigidBody->parent == mParent) {
// Play the hit animation
Projectile* projectile = (Projectile*)((char*)aRigidBody - offsetof(Projectile, rigidBody));
projectileHit(projectile);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment