I have extracted the CharacterController from the BEPU demo and have it working in a different program. I have a collision listener on a StaticCollidable, and about 50% of the time when the character comes into contact with the volume it seems to be missing its entity.
I'm using a InitialCollisionDetectedEventHandler<EntityCollidable> to listen for collisions, which has this signiture: public void CollisionHandler( EntityCollidable sender, Collidable other, CollidablePairHandler collisionPair ). In my case 'other' is the character controller's cylinder shape, but when I collide sometimes the Entity is null, and the Tag is null, even though the rest of the data for the cylinder seems to be intact. Other times when I collide the data will be there as it should. Is there something I could be doing that's causing the cylinder (mobilecollidable) to lose its entity and tag?
Collision issue with CharacterController and listener
-
- Posts: 11
- Joined: Sun Mar 24, 2013 10:27 pm
Re: Collision issue with CharacterController and listener
The character performs queries using proxy collidables, and these proxies would lack the entity and tag associated with the 'real' character collidable.In my case 'other' is the character controller's cylinder shape, but when I collide sometimes the Entity is null, and the Tag is null, even though the rest of the data for the cylinder seems to be intact. Other times when I collide the data will be there as it should. Is there something I could be doing that's causing the cylinder (mobilecollidable) to lose its entity and tag?
I suspect the events are being dispatched during proxy collidable queries because of an old oversight. It should have been fixed on December 8, 2012, so if you're using an older version than that, I would recommend upgrading to a more recent version. The relevant change is in the QueryManager used by the CharacterController; you can fix it manually if you want by adding a pairHandler.SuppressEvents = true and pairHandler.SuppressEvents = false around the pairHandler.UpdateCollision(0) in QueryManager.QueryContacts, like so:
Code: Select all
...
if (pairHandler.CollisionRule == CollisionRule.Normal)
{
pairHandler.SuppressEvents = true;
pairHandler.UpdateCollision(0);
pairHandler.SuppressEvents = false;
foreach (var contact in pairHandler.Contacts)
{ ...