protected virtual void Awake() { if (shipCollider != null) { shipCollider.Initalise(this); } if (shieldCollider != null) { shieldCollider.Initalise(this); } boid = GetComponent <BoidActor> (); foreach (Debris debris in debrisObjects) { debris.gameObject.SetActive(false); } foreach (Gun gun in guns) { gun.ship = this; } if (engineAudioSource != null) { if (engineAudioSource.clip != null) { engineAudioSource.time = Random.Range(0f, engineAudioSource.clip.length); } } }
protected virtual void Awake() { boid = GetComponent <BoidActor> (); if (enabled) { calculationsCo = StartCoroutine(UpdateCalculations()); } }
public bool AimingAt(BoidActor targetBoid, float accuracy) { float timeToTarget = Vector3.Distance(targetBoid.transform.position, ship.transform.position) / projectileSpeed; Vector3 targetPosition = targetBoid.transform.position + (targetBoid.velocity * timeToTarget); if (Vector3.Angle(ship.transform.forward, targetPosition - ship.transform.position) <= accuracy) { return(true); } else { return(false); } }