Collision event help
Posted: Thu Sep 01, 2011 12:39 am
I have a triangle mesh being used for my world map and a cylinder for my player. using the box example from the getting started demo for a projectile i am trying to get an event to happen when the player collides with the projectile. lets say when the player collides with a projectile subtract 1 from a float for player health. i have added a collision event to the player entity using the line Player.CollisionInformation.Events.PairCreated += Events_PairCreated; and the event handler being
void Events_PairCreated(EntityCollidable sender, BEPUphysics.BroadPhaseSystems.BroadPhaseEntry other, INarrowPhasePair pair)
{
//playerHealth -= 1;
//throw new NotImplementedException();
var otherEntityInformation = other as EntityCollidable;
if (otherEntityInformation != null)
{
playerHealth -= 1;
}
}
the problem i run into is the player loses health no matter what the projectile collides with. are there any tutorials that may explain collision events a little more in detail than http://bepuphysics.codeplex.com/wikipag ... umentation. do i need to add a collision rule and if so how would i do this? i have read through http://bepuphysics.codeplex.com/wikipag ... umentation but im having trouble understanding this. if some one could point me in the right direction would be great.
void Events_PairCreated(EntityCollidable sender, BEPUphysics.BroadPhaseSystems.BroadPhaseEntry other, INarrowPhasePair pair)
{
//playerHealth -= 1;
//throw new NotImplementedException();
var otherEntityInformation = other as EntityCollidable;
if (otherEntityInformation != null)
{
playerHealth -= 1;
}
}
the problem i run into is the player loses health no matter what the projectile collides with. are there any tutorials that may explain collision events a little more in detail than http://bepuphysics.codeplex.com/wikipag ... umentation. do i need to add a collision rule and if so how would i do this? i have read through http://bepuphysics.codeplex.com/wikipag ... umentation but im having trouble understanding this. if some one could point me in the right direction would be great.