I have this ship flying demo I am creating. I can move the ship and fly and swoop and whatever, but the issue is with the laser projectiles being fired. It seems to do fine when I am close to absolute (0,0,0), but the farther I fly away from that point the lasers don't appear on the ship anymore, they appear.
Here is the constructor for the Laser:
Code: Select all
//Ship is a ship which contains information about the ship as well as the ship' node
//CannonPosition is the position of the cannon firing the laser relative to the center of the ship
//TargetDirection is the direction the laser is being fired in
public Laser(Ship ship, Vector3D CannonPosition, Vector3D TargetDirection)
{
lasernode = new LaserBeamNode(null, ship.smgr, 200, "green.bmp");
lasernode.StartPoint = ship.Node.Position + CannonPosition;
//InitPosition is the original position of the laser, used to destroy a laser after it has gone a certain distance without colliding with something.
InitPosition = ship.Node.AbsolutePosition + CannonPosition;
lasernode.EndPoint = ship.Node.Position + CannonPosition + (TargetDirection * 100);
lasernode.BeamColor = ship.LaserColor;
lasernode.BeamScale = 1;
direction = TargetDirection;//*/
}
NOTE: THis is in C# using Irrlicht.NET CP, but the code should be easy enough to read for all the c++ users out there. I read the c++ to get my ideas when using c#.
Thanks for the help