WeaponMainDir: The Simple Way
WeaponMainDirX is a vector showing the direction of the weapon's aiming cone. MaxAngleDifX is the size of the aiming cone. With these tags you can limit the firing arc of weapons.
If you want to precisely choose the WeaponMainDir, you could run UpSpring, create a new piece, move it around until the line, from the origin, to your piece, is along the line you want your weapon to fire, then write down the coordinate in WeaponMainDir. Keep in mind UpSpring invert the sign of the axis x and z.
--old confusing explanation removed; if you want it see history--
Example: forward firing gun
For instance, if you want your Primary Weapon to have a 90° fire arc forward, you'd write:
WeaponMainDir1=0 0 1; //x:0 y:0 z:1 => that's forward! MaxAngleDif1=90; //90° from side to side, or 45° from center to each direction
Example: two turrets on the sides of a unit
This unit that has one turret at left side and one turret at right side.
Each turret can rotate around 220°, a bit more then a semi circle which would be 180° This way each turret can only shot at its side.
The fireing arcs overlap at front and back so both turrets can fire there:
To archieve this effect, the unitdef's weapon section looks like this:
weapons = {
{
def = [[Flamer]],
mainDir = [[1 0 0]],
maxAngleDif = 220,
},
{
def = [[Flamer]],
mainDir = [[-1 0 0]],
maxAngleDif = 220,
},
}
by this manner the unit is aware of the restricted angle of own weapon and will search to make weapon1 in the line of sight if not frontal ; but for more complexe restriction (ie:multiple or not conic ) writing a "IF" is mandatory in animdefs (but the unit will not try to reach the line of sight in this case and just disable the turn or the shoot if not in the alowed angles or condition)
