Ok, I have another small problem. I am trying to simulate a bullet object by the following code:
public void fireShotgun () {
if (pelletsTraveling) {
pellets [0].Delete ();
pellets [1].Delete ();
}
pellets = new Sphere [] { new Sphere (10.0f), new Sphere (10.0f) };
pellets [0].Position (cam.PositionX, cam.PositionY, cam.PositionZ);
pellets [1].Position (cam.PositionX, cam.PositionY, cam.PositionZ);
pellets[1].SetOrientation (cam);
pellets [1].Rotate (1.0f, -1.0f, 0.1f); //simulate randomly patterning pellets
pelletsTraveling = true;
}
public void movePellets () {
pellets [0].Move (10.0f);
pellets [1].Move (10.0f);
if (target.Collision () == pellets [0] || target.Collision () == pellets [1]) {
Text.ShowText (10, 10, "Hit target");
}
}
//my run method for updating bullets (in my main loop)
if (pelletsTraveling) {
movePellets ();
travelSteps--;
if (travelSteps < 0) {
pelletsTraveling = false;
travelSteps = 100;
}
}
the bullets fire and update fine, but the problem is the way they move. I am trying to make them fire directly away from where my camera is pointing but they always seem to fire in the same direction regardless of where the camera is pointing. Anyone have a suggestion?