// Update is called once per frame void Update() { // Rotate if (target && target.gameObject.activeSelf) { float dist = Vector3.Distance(target.position, transform.position); if (dist > 30f) { thruster.SetTargetDirection(target.position - transform.position); } float angle = Vector3.Angle(target.position - transform.position, transform.forward); if (angle < 5.0f) { FireWeapon(); } } else { AssignTarget("Cargo"); } if (target == null) { thruster.thrustSpeedCurr = 0f; } }
// Update is called once per frame void Update() { // Rotate if (target) { float dist = Vector3.Distance(target.position, transform.position); if (dist > 30f) { thruster.SetTargetDirection(target.position - transform.position); thruster.SetThrustSpeed(thruster.thrustSpeedBase); thruster.SetThrustV(1f);// Go thruster.BrakeOff(); } else { thruster.SetThrustV(1f); thruster.SetThrustSpeed(thruster.thrustSpeedBase * 0.5f);// SLOW thruster.BrakeOff(); levelController.ProcessArrival(gameObject, target.gameObject); } } else { EventManager.TriggerEvent("haulerLost"); } }