When I run the collision code, there are no errors, but when I shoot the enemy nothing happens..... Any problems that are blindingly obvious?
Class Level Variables
public Model model { get; protected set; }
Collision Code
public bool CollidesWith(Model otherModel, Matrix otherWorld)
{
// Loop through each ModelMesh in both objects and compare
// all bounding spheres for collisions
foreach (ModelMesh myModelMeshes in model.Meshes)
{
foreach (ModelMesh hisModelMeshes in otherModel.Meshes)
{
if (myModelMeshes.BoundingSphere.Transform(
GetWorld()).Intersects(
hisModelMeshes.BoundingSphere.Transform(otherWorld)))
return true;
}
}
return false;
}
Debugger.Break()
(or throwing an exception) for methods when "nothing happens." That helps troubleshoot real fast (eg. not building inAny CPU
so can't debug easily). – ashes999 Aug 19 at 10:12myModelMeshes.BoundingSphere.Transform(GetWorld())
should be saved in a variable -- it only needs to be done once per iteration of the outer loop, not repeatedly in the inner loop. – bobobobo Aug 19 at 14:58