ST_Turret : MF_AbstractPlatform
Describes the properties of a turret, and it will control the aiming of your turret. Place this in the root GameObject of your turret. Typically, this will be aiming a weapon at a target, but can be used with cameras, or other rotating objects.
Inherited Variables
target, weaponMount, aimObjectActive, aimObject, emptyAimRange, fixedAimObjectRange, useIntercept, useRootVelocity, velocityRoot, shotSpeed, exitLoc, targetAimLocation, targetRange, lastTargetPosition, targetRigidbody, velocity, playerControl
Inherited Methods
Override AimLocation : Vector3 ()
Adjusts aim location based on intercept and ballistic settings.
Override TargetWithinLimits : bool ( targ : Transform )
Returns true if targ is within the turning limits of the turret.
Override AimCheck : bool ( targetSize : float, aimTolerance : float )
Returns true if the turret is aimed properly to hit the target. This takes into account the intercept and ballistics.
Public Variables
useGravity : bool
Aim as if the shots will be affected by gravity. Assumes zero drag.
defaultArc : ArcType enum { Low, High }
When firing ballistic shots affected by gravity, most firing solutions will have both a high arc and a low arc. SmoothTurret will pick the specified arc. High arc requires more computation cycles to achieve reasonable accuracy.
ballisticIterations : int
Using intercept and ballistics at the same time is an iterative function. This will specify how many times to run the process for the lower arc trajectory. Higher numbers result in greater accuracy, at the expense of processor usage. Longer flight times generally require more iterations to achieve acceptable accuracy. For the lower arc, 1 is likely to be acceptable for most applications.
highArcBallisticIterations : int
Using intercept and ballistics at the same time is an iterative function. This will specify how many times to run the process for the higher arc trajectory. Higher numbers result in greater accuracy, at the expense of processor usage. Longer flight times generally require more iterations to achieve acceptable accuracy. Since the high arc flight times tend to be much larger than the low arc, the default is set to 5.
rotationRateMax : float
elevationRateMax : float
The maximum rate in degrees per second that each part may turn. Note, that often times your turret may not reach higher maximum turn rates. This is due to two main factors. First, the turret will also need time to slow down at some point before it reaches its destination, effectively limiting how fast it can turn. Second, there will typically only be 180 degrees max to rotate to its goal. Between the time needed to accelerate and slow down, there may not be enough degrees to hit the max turn rate before reaching its goal.
These will also have an effect on the pitch/rate of the rotator and elevator motion sounds.
rotationAccel : float
elevationAccel : float
The acceleration rate of the rotator and elevator parts of the turret. This is how fast that part speeds up and slows down its turning.
decelerateMult : float
This allows you to cause deceleration to be a different rate than accelerating. It affects both rotation and elevation. Typically, this value will be used to simulate braking being easier than accelerating.
constantTurnRate : bool
This allows you to forgo smooth natural movement, and have the turret simply use constant turn rates. This setting uses less computation, and is also typically better for turrets using very fast turn rates. Accuracy is also better than using smooth turning.
If this option is used, the turret will turn at the rate supplied in rotationAccel and elevationAccel but will still be limited by rotationRateMax and elevationRateMax.
limitLeft : float (0 to -180)
limitRight : float (0 to 180)
limitUp : float (0 to 90)
limitDown : float (0 to -90)
Each of these allow you to place traversal limits on the rotator and elevator parts. Movement tracking left and down use negative numbers. Tracking to the right and up use positive numbers.
restAngle : Vector2
You may define an angle for the turret to point when it has no target.
x is the angle of elevation (-90 to 90).
y is the angle of rotation (-180 to 180).
0, 0 points straight ahead.
restDelay : float
The time in seconds a turret will remain at its current position without a target before turning to its restAngle.
aimError : float
aimErrorInterval : float
Optionally, you can give the turret some inaccuracy in rotation. aimError is the inaccuracy in degrees, and aimErrorInterval is how often a new random ‘wrong’ position is calculated. These values typically look best when under 1, with the interval looking better higher when turn rates are slower.
turningWeapInaccuracy : float
Adds to weapon inaccuracy if the turret is turning, for every degree per second, from both the elevator and rotator parts. ST_TurretControl will send this value to every weapon in the turret. But will be bound by each individual weapon's inaccuracy on the low end, and maxInaccuracy found in ST_TurretControl on the high end.
rotator : Transform
The object that rotates around the y axis.
elevator : Transform
The object that rotates around the x axis.
rotatorSound : AudioObject
elevatorSound : AudioObject
These control the audio to be used for each part’s movement sound. This sound will play at a varying pitch/rate based on the current rotation/elevation speed as compared to its respective maximum.
For best results, this sound should be a constant looping whir or hum. Steady looping rhythmic elements work well too, as their rate will also vary with the turning speed.
Hidden Variables
systAimError : Vector3
The current location of any error introduced with aimError. This will change every aimErrorInterval seconds.
averageRotRateEst : float
averageEleRateEst : float
Used to smooth the current rotation and elevation reading because of spikes from inconsistent frame rates.
totalTurnWeapInaccuracy : float
The amount of inaccuracy ST_TurretControl will send to weapons resulting from turningWeapInaccuracy * (averageRotRateEst + averageEleRateEst)
curArc : ArcType enum { Low, High }
The current ballistic arc being used. This can be modified by ST_TurretControl if the default arc LoS is blocked, and losMayChangeArc is used.
Public Class AudioObject
audioSource : AudioSource
The audio source used for audio.
pitchMax : float
The maximum pitch the audio can be played at. This is reached when turning at full speed.
pitchMin : float
The minimum pitch the audio can be played at. This is the pitch that is approached as the turning motion slows.
Describes the properties of a turret, and it will control the aiming of your turret. Place this in the root GameObject of your turret. Typically, this will be aiming a weapon at a target, but can be used with cameras, or other rotating objects.
Inherited Variables
target, weaponMount, aimObjectActive, aimObject, emptyAimRange, fixedAimObjectRange, useIntercept, useRootVelocity, velocityRoot, shotSpeed, exitLoc, targetAimLocation, targetRange, lastTargetPosition, targetRigidbody, velocity, playerControl
Inherited Methods
Override AimLocation : Vector3 ()
Adjusts aim location based on intercept and ballistic settings.
Override TargetWithinLimits : bool ( targ : Transform )
Returns true if targ is within the turning limits of the turret.
Override AimCheck : bool ( targetSize : float, aimTolerance : float )
Returns true if the turret is aimed properly to hit the target. This takes into account the intercept and ballistics.
Public Variables
useGravity : bool
Aim as if the shots will be affected by gravity. Assumes zero drag.
defaultArc : ArcType enum { Low, High }
When firing ballistic shots affected by gravity, most firing solutions will have both a high arc and a low arc. SmoothTurret will pick the specified arc. High arc requires more computation cycles to achieve reasonable accuracy.
ballisticIterations : int
Using intercept and ballistics at the same time is an iterative function. This will specify how many times to run the process for the lower arc trajectory. Higher numbers result in greater accuracy, at the expense of processor usage. Longer flight times generally require more iterations to achieve acceptable accuracy. For the lower arc, 1 is likely to be acceptable for most applications.
highArcBallisticIterations : int
Using intercept and ballistics at the same time is an iterative function. This will specify how many times to run the process for the higher arc trajectory. Higher numbers result in greater accuracy, at the expense of processor usage. Longer flight times generally require more iterations to achieve acceptable accuracy. Since the high arc flight times tend to be much larger than the low arc, the default is set to 5.
rotationRateMax : float
elevationRateMax : float
The maximum rate in degrees per second that each part may turn. Note, that often times your turret may not reach higher maximum turn rates. This is due to two main factors. First, the turret will also need time to slow down at some point before it reaches its destination, effectively limiting how fast it can turn. Second, there will typically only be 180 degrees max to rotate to its goal. Between the time needed to accelerate and slow down, there may not be enough degrees to hit the max turn rate before reaching its goal.
These will also have an effect on the pitch/rate of the rotator and elevator motion sounds.
rotationAccel : float
elevationAccel : float
The acceleration rate of the rotator and elevator parts of the turret. This is how fast that part speeds up and slows down its turning.
decelerateMult : float
This allows you to cause deceleration to be a different rate than accelerating. It affects both rotation and elevation. Typically, this value will be used to simulate braking being easier than accelerating.
constantTurnRate : bool
This allows you to forgo smooth natural movement, and have the turret simply use constant turn rates. This setting uses less computation, and is also typically better for turrets using very fast turn rates. Accuracy is also better than using smooth turning.
If this option is used, the turret will turn at the rate supplied in rotationAccel and elevationAccel but will still be limited by rotationRateMax and elevationRateMax.
limitLeft : float (0 to -180)
limitRight : float (0 to 180)
limitUp : float (0 to 90)
limitDown : float (0 to -90)
Each of these allow you to place traversal limits on the rotator and elevator parts. Movement tracking left and down use negative numbers. Tracking to the right and up use positive numbers.
restAngle : Vector2
You may define an angle for the turret to point when it has no target.
x is the angle of elevation (-90 to 90).
y is the angle of rotation (-180 to 180).
0, 0 points straight ahead.
restDelay : float
The time in seconds a turret will remain at its current position without a target before turning to its restAngle.
aimError : float
aimErrorInterval : float
Optionally, you can give the turret some inaccuracy in rotation. aimError is the inaccuracy in degrees, and aimErrorInterval is how often a new random ‘wrong’ position is calculated. These values typically look best when under 1, with the interval looking better higher when turn rates are slower.
turningWeapInaccuracy : float
Adds to weapon inaccuracy if the turret is turning, for every degree per second, from both the elevator and rotator parts. ST_TurretControl will send this value to every weapon in the turret. But will be bound by each individual weapon's inaccuracy on the low end, and maxInaccuracy found in ST_TurretControl on the high end.
rotator : Transform
The object that rotates around the y axis.
elevator : Transform
The object that rotates around the x axis.
rotatorSound : AudioObject
elevatorSound : AudioObject
These control the audio to be used for each part’s movement sound. This sound will play at a varying pitch/rate based on the current rotation/elevation speed as compared to its respective maximum.
For best results, this sound should be a constant looping whir or hum. Steady looping rhythmic elements work well too, as their rate will also vary with the turning speed.
Hidden Variables
systAimError : Vector3
The current location of any error introduced with aimError. This will change every aimErrorInterval seconds.
averageRotRateEst : float
averageEleRateEst : float
Used to smooth the current rotation and elevation reading because of spikes from inconsistent frame rates.
totalTurnWeapInaccuracy : float
The amount of inaccuracy ST_TurretControl will send to weapons resulting from turningWeapInaccuracy * (averageRotRateEst + averageEleRateEst)
curArc : ArcType enum { Low, High }
The current ballistic arc being used. This can be modified by ST_TurretControl if the default arc LoS is blocked, and losMayChangeArc is used.
Public Class AudioObject
audioSource : AudioSource
The audio source used for audio.
pitchMax : float
The maximum pitch the audio can be played at. This is reached when turning at full speed.
pitchMin : float
The minimum pitch the audio can be played at. This is the pitch that is approached as the turning motion slows.