void Update() { // If we don't currently have a target pickup then target the nearest one. If we do // have a target and we are within detection range then pick it up. if (target == null) { target = PickupSensor.GetNearestByComponent <Holdable>(); if (target != null) { Steering.IgnoreList.Clear(); Steering.IgnoreList.Add(target.gameObject); Steering.DestinationTransform = target.transform; } } else if (InteractionRange.IsDetected(target.gameObject)) { // Pickup the target.. (Destroy it to show it has been picked up) Destroy(target.gameObject); target = null; } }
void Start() { rb = GetComponent <Rigidbody>(); isInteracting = false; held = null; }