I'm trying to implement the collision for a flamethrower-type weapon. Basically, I thought that I could take a Box, lock the position and orientation to the camera, and then look for any enemies in its contact list each frame and damage them. I don't know how to make the box stay in the same place relative to my camera without manually changing the position and orientation, though; and that obviously messes with the collision detecting. Also, when I did that, the box seemed to change its shape in weird ways. What's the best way to do this?
Also, if you have better ideas of how to check the box's contacts, I would appreciate it.
Right now the Update function (which is called from my player's Update) looks like this:
Code: Select all
public void Update(double elapsedmillis, Vector3 position, Quaternion orientation)
{
box.Position = position;
box.Orientation = orientation;
lastTick += elapsedmillis;
if (lastTick >= tickRate)
{
lastTick = 0;
foreach (CollidablePairHandler c in box.CollisionInformation.Pairs)
{
Entity e = c.EntityB;
if (e != null)
{
Robot r = e.CollisionInformation.Tag as Robot;
if (r != null)
{
r.Hit();
}
}
}
}
}