   special action when collision
  Hello, I have done a small physic engine for points and I used the points to place my meshes. My engine have points and different kind of interaction (friction, collision, etc).I would like to make actions done by objects outside of the physic engine (creation of dust, explosion, etc) when there is a collision. However, I wonder how to inform or check that a point has been in collision, because the only information I can get yet outside of the engine are the positions of the points.I am thinking about doing a special class for the class Collision, that have a link to an object "CollisionReaction", that is outside of the physic engine. When there is a collision, Collision call the method "IsCollision" of "CollisionReaction". Depending of the kind of the CollisionReaction used, it would do something different (dust, explosion, etc).It may be like the pattern Observer: the physical point is the observed and CollisionReactions are the observers.Does somebody have an idea about how I should inform objects outside of the physic engine that a point has been in collision???Thanks!!!   
  My physics engine has an interface called "collisionresponse" that different classes can implement. Whenever a physics polygon is created I pass in an object that implements this interface and whenever that polygon hits something the collide method is called on whatever object was passed in at creation time. This seems works pretty well in that each of my game objects gets a chance to respond to its collisions in its own way and the code stays pretty organized. Also the parent objects come in very handy not just for informing an object that it was hit but what it was hit by ( collidedpolygon.parent ). Here's the actual interface:public interface collisionresponse{//called from physics engine when a collision occurs//variables include //exact position of collision//projection applied to this collision part to resolve the collision//the force applied to this polygon as a result of the collision//the polygon linked to this object that threw the collision method//the other objects polygon that was collided with//note the double arrays passed are temporary and should be copied if they are to be savedpublic abstract void collide(double position[],double projection[],double force[], physicalpolygon mypolygon,physicalpolygon collidedpolygon);}and here's an implementation on an enemy ship in an upward scrolling shooter:public void collide(double position[],double projection[],double force[], physicalpolygon mypolygon,physicalpolygon collidedpolygon){unit cr = (unit)collidedpolygon.parent ;//gameo bject collided withif(cr instanceof bullet && cr.faction !=faction){//if a bullet from a different teambullet b = ((bullet)cr) ;health-=b.damage ;//take the damageif(b.parent instanceof playership){//if a bullet from a playership((playership)b.parent).score+=difficulty*b.damage/maxhealth ;// then reward points for damage}}};  @ Alrecenk: Your fonction looks great. Howerver, the elements of my physic engine do not have link to collidedpolygon.parent. Even if it is necessary to react with different behaviors, it obliges to use the type of collidedpolygon.parent to print the objects of your physic engine, isn't it??? Please tell me if I am wrong!!! If not, I am thinking about adding an int myID as an attribute to each object of my physic engine (ex: bullets would have myID = 1, etc).The pattern observer seems also good to me: severals objects can observe the collision of a physical object, start or stop to observe whenever they want. But it may be a little heavy and complicated.Please tell me what you think about all of this!!!   ;Quote:However, the elements of my physic engine do not have link to collidedpolygon.parent. Even if it is necessary to react with different behaviors, it obliges to use the type of collidedpolygon.parent to print the objects of your physic engine, isn't it??? Please tell me if I am wrong!!! If not, I am thinking about adding an int myID as an attribute to each object of my physic engine (ex: bullets would have myID = 1, etc).I don't really get what you are asking, but the advantage to using a parent object over just an identification number is that the collision can call the collision method on the parent object. Also, there's a lot more information available for collision response if you have access to the object actually collided with. Like in my example code I pull the amount of damage information off of the bullet object itself, which allows for different bullets to do different amounts of damage easily.As far as observer set-ups go I have no idea how well that works. I've only tried the naive method of having all my collision code in one place for small games, and the above set-up for my more recent stuff. I can say that this this event-driven way works pretty well.   