Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualic0de

Posted 22 July 2013 - 07:00 PM

Or, why not have the code that creates an explosion gather all the enemies close to the center of the explosion, and then get the btRigidBody member from it when you apply the physics. If you're wanting to apply both the physical force and the damage from the same method, then you don't really want the rigid body, but the enemy. Otherwise, and perhaps better, would be to separate concerns and not apply forces and deal damage in the same method.

 

I don't actually apply forces and deal damage in the same function I just notify the enemy that it has been hit and how hard. The enemy class itself decides how damage is dealt. The reason I gather up rigidBodys instead of enemies is because bullet has a simple way to gather all the objects that overlap with an arbitrary collision shape. I'll look into BeerNutts suggestion. 

 

EDIT: I looked into it and bullet provides setUserPointer/getUserPointer functions, I'm surprised I overlooked that.


#1ic0de

Posted 22 July 2013 - 06:37 PM

Or, why not have the code that creates an explosion gather all the enemies close to the center of the explosion, and then get the btRigidBody member from it when you apply the physics. If you're wanting to apply both the physical force and the damage from the same method, then you don't really want the rigid body, but the enemy. Otherwise, and perhaps better, would be to separate concerns and not apply forces and deal damage in the same method.

 

I don't actually apply forces and deal damage in the same function I just notify the enemy that it has been hit and how hard. The enemy class itself decides how damage is dealt. The reason I gather up rigidBodys instead of enemies is because bullet has a simple way to gather all the objects that overlap with an arbitrary collision shape. I'll look into BeerNutts suggestion. 


PARTNERS