void GetClosestInteraction() { if (hitColliders.Length == 0) //No Available Interactions { return; } currentShortestDistance = controllerData.maxSearchDistance; for (int i = 0; i < hitColliders.Length; i++) { distanceBetweenObjectsInLoop = Vector3.Distance(transform.position, hitColliders[i].transform.position); if (distanceBetweenObjectsInLoop < currentShortestDistance) //Is Shorter than the current distance { if (nearestAvailableInteraction != null) { if (nearestAvailableInteraction.transform != hitColliders[i].transform) { LeaveClosestInteractionRange(); } } nearestAvailableInteraction = hitColliders[i].GetComponent <WorldInteractionController>(); currentShortestDistance = distanceBetweenObjectsInLoop; } } }
public void RemoveInteraction(WorldInteractionController controller) { interactions.Remove(controller); }
public void AddNewInteraction(WorldInteractionController controller) { interactions.Add(controller); controller.Init(); }
public override void ExecuteWorldInteraction(WorldInteractionController interaction, InteractionSearcherController playerInteracting) { interaction.GetComponent <WorldInteractionEvent_PickupWeaponRuntime>().PickupWeapon(playerInteracting); }
public virtual void ExecuteWorldInteraction(WorldInteractionController interaction, InteractionSearcherController playerInteracting) { }
void LeaveClosestInteractionRange() { nearestAvailableInteraction = null; }