Page tree
Skip to end of metadata
Go to start of metadata


Introduced in

Version:1.19

Description

Description:Sets the direction of a turret or weapon.

The given direction is in world coordinates, so it is independent of the vehicle orientation. In the case of units, the direction is relative to the unit direction.

To lock a turret to a relative hull position, use fn vbs lockTurretDir.

Syntax

Syntax:vehicle setWeaponDirection [turretPath, [azimuth, elevation], transition]
Parameters:
  • vehicle: Object - Affected vehicle (must has a gunner, whose input has been disabled, using disableGunnerInput).
  • turretPath: Array - Turret path.
  • azimuth: Number - Turret / weapon azimuth (in degrees).
  • elevation: Number - Turret / weapon elevation (in degrees).
  • transition: Boolean - If set to true, the direction transition is gradual; if false, the transition is instantaneous (optional, default: true).
Return Value:Nothing

Alternative Syntax

Syntax:unit setWeaponDirection [[azimuth, elevation], transition] (before V1.30, only available in the TWS build)
Parameters:
  • unit: Object - Player unit (whose input has been disabled, using disableGunnerInput 1 or disableGunnerInput 3 - see disableGunnerInput).
  • azimuth: Number - Turret / weapon azimuth (in degrees, relative to the unit body direction).
  • elevation: Number - Turret / weapon elevation (in degrees).
  • transition: Boolean - If set to true, the direction transition is gradual; if false, the transition is instantaneous (optional, default: true).
Return Value:Nothing

Examples

Examples:
_tank1 SetWeaponDirection [[0],[90,5]]
player SetWeaponDirection [[0,30],false]

Additional Information

See also: turretWeaponDirection, setOpticsDirection, changeTurretDirection, deployWeapon, setTurretMaster, fn_vbs_lockTurretDir
Multiplayer:
Problems:Between V1.40 - V1.69, the effect on the player is only temporarily (for a fraction of a second), and resets immediately.

Notes


Note the alternative syntax allows for relative azimuth, but not relative elevation. You can adapt this psudo-code to convert a relative elevation to an absolute one:

 //get current azimuth / elevation
_wdir = (_veh turretWeaponDirection [_turret]) call fn_vbs_vectorToDir;
_curAzimuth = _wdir select 0;
_curElev = _wdir select 1;

//factor in hull direction to find desired azimuth in absolute terms
_vdir = getdir _veh;
_tgtAzimuth = (_azimuth + _vdir) % 360;

//factor in hull pitch at target azimuth to find desired elevation in absolute terms
_tgtElev = _elev + (cos (_vdir-_tgtAzimuth))*((_veh call fn_vbs_getPitchBank) select 0);