Skip to main content

ProjectileShooter

A class in Root.Township, Alta.Intelligence.

Component that spawns and fires a projectile from a creature, aimed forward or at its target with some random spread. Server only; nothing in code calls Shoot, so prefab events probably do.

Constructors​

MemberWhat it is
ProjectileShooter()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

7 private and internal fields
MemberWhat it is
private Agent agentThe creature shooting. Its target is aimed at and it becomes the projectile's Shooter.
private ProjectileShooter.AimMode aimModeHow to aim: Forward, Target, or a mix of forward and the target direction for the vertical or horizontal part.
private Transform directionTransform whose forward is used as the forward aim. Falls back to this transform.
private float maximumAccuracyAngleLargest random spread in degrees (default 5). 0 shoots perfectly straight.
private Projectile projectilePrefabThe projectile spawned.
private float velocityMaximumHighest launch speed (default 15).
private float velocityMinimumLowest launch speed (default 15).

Properties​

MemberWhat it is
float InaccuracyMultiplier { get; set; }Scales the random spread angle (default 1). Nothing in code sets it.
float VelocityMultiplier { get; set; }Scales the launch speed (default 1). Nothing in code sets it.

Methods​

MemberWhat it is
void Shoot()Server: fires a projectile at the end of the frame.
2 private and internal methods
MemberWhat it is
private Vector3 SetY(Vector3 vector, float y)Returns the vector's flat direction rescaled so its Y component is the given value and its length is 1.
private IEnumerator ShootAtEndOfFrame() (iterator)Coroutine behind Shoot: skips dead creatures, aims, adds spread, spawns the projectile in the creature's chunk and sets the creature as its shooter.