ST_TurretControl : MF_AbstractPlatformControl
ST_TurretControl will allow for AI or Player control of the turret. It bridges communication between the turret, weapon, and targeting scripts, and is placed on the same object that holds the ST_Turret script. This is designed to be used with the MF_AbstractWeapon, and MF_AbstractTargeting scripts. If you wish to use different scripts, they'll either have to inherit the abstracts, or a new fire control script will need to be written to interface with the turret.
In addition, it will also read any inaccuracy caused from turret rotation and elevation, and send it to the weapons to simulate degradation of aim while parts are in motion.
In short, this script holds pointers to the weapons this turret has, and includes some aiming and behavior information. It asks the turret if it is aimed at the target. If it is, it then asks the weapon if it is ready to fire. If so, then sends a fire command to the weapon.
Inherited Variables
targetingScript, weapons, aimTime, curWeapon
Inherited Classes
WeaponData
Public Variables
target : GameObject
Current target of the turret. This will either be supplied by the targeting script, or be assigned directly. However, if the turret is choosing its own targets with a targeting script, this may immediately be overwritten.
controller : ControlType enum { AI_AutoTarget, None, Player_Mouse, Player_Click }
AI_AutoTarget: AI will use a scanner and a targeting script to pick targets. If no targeting script is picking targets, you may directly assign a target.
None: Turret is deactivated.
Player_Mouse: Turret will aim at the defined player’s aimObject in ST_Player, and will fire when the player presses the left mouse button. That player must also have turretControl set to true. If false, the turret will not fire or move.
Player_Click: Turret will aim and fire at a clicked location. If fullBurst is true, it will fire a full burst according to the weapon. Otherwise, a single shot is fired.
playerScript : ST_PlayerScript
Used when controller is set to Player_Mouse or Player_Click. This will give the turret that player’s aimObject as its target.
fixedConvergeRange : float
When using multiple weapons, you may designate a range that weapon fire will converge at using fixedConvergeRange. This will make the weapons angle slightly during Start() at runtime.
dynamicConverge : bool
If true, weapons will ignore fixedConvergeRange, and continuously angle to produce convergence at the range of the current target.
convergeSlewRate : float
Determines how fast the individual weapons will angle in degrees per second during dynamicConverge.
minConvergeRange : float
You may also designate a minimum convergence range, so as to limit the amount that the individual weapons can move.
alternatingFire : bool
When using multiple weapons, you can choose to have them all fire at once, or alternate shots between them. If alternating, the delay before the next weapons fires is the cycleTime of the weapon at index 0 divided by the number of weapons. This will produce odd results if you have weapons with different rates of fire.
fullBurst : bool
If true, when the weapon fires, a full burst will be unleashed according to the settings of MF_AbstractWeapon. If 0 or 1 is selected in burstAmount, it will still function as a single shot.
checkLOS : bool
Select if the turret should use line of sight to determine whether or not to fire. If using gravity, LoS will use a ballistic arc approximation. (Raycast from gun exit, to apex of the arc, to the target.)
alwaysDirectLos : bool
If true, LoS checks will always be directly from the gun exit to the target, and will not approximate a ballistic arc.
losMayChangeArc : bool
If true, when using gravity, if the LoS is blocked along the default arc, the turret will attempt to try the other arc. This will reset back to the default after every shot or change of target.
losCheckInterval : float
If performance becomes an issue, you can define an interval to wait between checks, although this can result in the weapon being less responsive to rapidly changing line of sight conditions. 0 = check before every shot.
maxInaccuracy : float
If the turret’s turningWeapInaccuracy is > 0, inaccuracy will be sent to the weapons. This will limit the amount of inaccuracy a weapon can have.
checkTargetSize : bool
This script tries to determine the target size when choosing whether or not to fire. This way, it will fire even if not aimed directly at the target center. It approximates the size of the target using the average dimension of the first root collider found. If no collider is found, it will look for the first collider in the root's children. If none found it will then check the children's children. If still none found, it will use targetSizeDefault.
targetSizeDefault : float
If no target size can be found, you can set a default size for the the weapons to fire at.
ST_TurretControl will allow for AI or Player control of the turret. It bridges communication between the turret, weapon, and targeting scripts, and is placed on the same object that holds the ST_Turret script. This is designed to be used with the MF_AbstractWeapon, and MF_AbstractTargeting scripts. If you wish to use different scripts, they'll either have to inherit the abstracts, or a new fire control script will need to be written to interface with the turret.
In addition, it will also read any inaccuracy caused from turret rotation and elevation, and send it to the weapons to simulate degradation of aim while parts are in motion.
In short, this script holds pointers to the weapons this turret has, and includes some aiming and behavior information. It asks the turret if it is aimed at the target. If it is, it then asks the weapon if it is ready to fire. If so, then sends a fire command to the weapon.
Inherited Variables
targetingScript, weapons, aimTime, curWeapon
Inherited Classes
WeaponData
Public Variables
target : GameObject
Current target of the turret. This will either be supplied by the targeting script, or be assigned directly. However, if the turret is choosing its own targets with a targeting script, this may immediately be overwritten.
controller : ControlType enum { AI_AutoTarget, None, Player_Mouse, Player_Click }
AI_AutoTarget: AI will use a scanner and a targeting script to pick targets. If no targeting script is picking targets, you may directly assign a target.
None: Turret is deactivated.
Player_Mouse: Turret will aim at the defined player’s aimObject in ST_Player, and will fire when the player presses the left mouse button. That player must also have turretControl set to true. If false, the turret will not fire or move.
Player_Click: Turret will aim and fire at a clicked location. If fullBurst is true, it will fire a full burst according to the weapon. Otherwise, a single shot is fired.
playerScript : ST_PlayerScript
Used when controller is set to Player_Mouse or Player_Click. This will give the turret that player’s aimObject as its target.
fixedConvergeRange : float
When using multiple weapons, you may designate a range that weapon fire will converge at using fixedConvergeRange. This will make the weapons angle slightly during Start() at runtime.
dynamicConverge : bool
If true, weapons will ignore fixedConvergeRange, and continuously angle to produce convergence at the range of the current target.
convergeSlewRate : float
Determines how fast the individual weapons will angle in degrees per second during dynamicConverge.
minConvergeRange : float
You may also designate a minimum convergence range, so as to limit the amount that the individual weapons can move.
alternatingFire : bool
When using multiple weapons, you can choose to have them all fire at once, or alternate shots between them. If alternating, the delay before the next weapons fires is the cycleTime of the weapon at index 0 divided by the number of weapons. This will produce odd results if you have weapons with different rates of fire.
fullBurst : bool
If true, when the weapon fires, a full burst will be unleashed according to the settings of MF_AbstractWeapon. If 0 or 1 is selected in burstAmount, it will still function as a single shot.
checkLOS : bool
Select if the turret should use line of sight to determine whether or not to fire. If using gravity, LoS will use a ballistic arc approximation. (Raycast from gun exit, to apex of the arc, to the target.)
alwaysDirectLos : bool
If true, LoS checks will always be directly from the gun exit to the target, and will not approximate a ballistic arc.
losMayChangeArc : bool
If true, when using gravity, if the LoS is blocked along the default arc, the turret will attempt to try the other arc. This will reset back to the default after every shot or change of target.
losCheckInterval : float
If performance becomes an issue, you can define an interval to wait between checks, although this can result in the weapon being less responsive to rapidly changing line of sight conditions. 0 = check before every shot.
maxInaccuracy : float
If the turret’s turningWeapInaccuracy is > 0, inaccuracy will be sent to the weapons. This will limit the amount of inaccuracy a weapon can have.
checkTargetSize : bool
This script tries to determine the target size when choosing whether or not to fire. This way, it will fire even if not aimed directly at the target center. It approximates the size of the target using the average dimension of the first root collider found. If no collider is found, it will look for the first collider in the root's children. If none found it will then check the children's children. If still none found, it will use targetSizeDefault.
targetSizeDefault : float
If no target size can be found, you can set a default size for the the weapons to fire at.