Callbacks

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
VVaari
Posts: 2
Joined: Mon Mar 09, 2009 8:15 am

Callbacks

Post by VVaari »

Hello,

Is there something like callback functions in entitys which get called if some other entity collides with it? It would be easy way to determine which entitys collided, or is there a better way to determine that?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Callbacks

Post by Norbo »

You can hook events to individual entities using the (Entity).addEventHook method. There are quite a few options to choose from, including events that fire when objects come close to each other, when they initially collide, and when they stop colliding.

If you want something more general without using events, like the ability to check all colliding pairs, you can iterate over the (Space).controllers list. These represent entity pairs which are candidates for collision. You can check if they are currently colliding by their current number of contacts (more than 0 means colliding).
VVaari
Posts: 2
Joined: Mon Mar 09, 2009 8:15 am

Re: Callbacks

Post by VVaari »

Oh yeah like that fish and barrel example. Thanks Norbo! Just started using bepu physics and it seems to be brilliant system :)
Post Reply