Hello,
I have been looking at the example of using the collision event handler in Panda3d. For my project, I would love to be able to have every collision fire an event and then assign and allow the necessary object(s) to handle each message appropriately and perform the appropriate action for that collision.
I would like each game object to contain a ‘handleCollision’ function that is called when the appropriate event is active. (like below)
# Accept the events sent by the collisions.
self.accept('into-someGameObject', self.collide)
self.accept('outof-SomeOtherGameObject', self.collide2)
However, I would like to have only one function for each object that handles ALL collision events that pertains to a specific game object, and thus need a unique way to extract the collision ‘description’ when the method is called. This would allow for a bit of encapsulation within existing game objects.
Is there a way to either extract the descriptions (in the example above, ‘into-someGameObject’/‘outof-SomeOtherGameObject’) from a given collision entry, or pass an additional argument that?
On another note, is it possible, or a good idea to use events for player-terrain collisions? The little bit I have experimented, it seems like I only receive one collision event when the player initially ‘collides’ with the terrain.
Will the event handler, continuously fire ‘player/terrain’ collision events, or is this where the ‘again’ pattern would need to be implemented?
Thanks and sorry for the lengthy/wordy post.
[/code]