// Called every frame protected void Update() { if (!controllerEnabled) { return; } // If a target exists ... if (targetLeader.Target != null) { // Track the target and fire gimbalController.TrackPosition(targetLeader.LeadTargetPosition, out firingAngle, false); UpdateFiring(); } // If a target doesn't exist ... else { // Return the turret to center if (noTargetReturnToCenter) { gimbalController.ResetGimbal(false); } if (firing) { StopFiring(); } } }
/// <summary> /// Rotate the gimbal to look at a specified world position. /// </summary> /// <param name="lookPosition">The world position to look at.</param> public virtual void TrackPosition(Vector3 targetPosition) { float angle; gimbalController.TrackPosition(targetPosition, out angle, false); if (independentRotationEnabled) { UpdateIndependentGimbalRotation(); } }