コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
 public void RemoveInteraction(WorldInteractionController controller)
 {
     interactions.Remove(controller);
 }
コード例 #3
0
 public void AddNewInteraction(WorldInteractionController controller)
 {
     interactions.Add(controller);
     controller.Init();
 }
コード例 #4
0
 public override void ExecuteWorldInteraction(WorldInteractionController interaction, InteractionSearcherController playerInteracting)
 {
     interaction.GetComponent <WorldInteractionEvent_PickupWeaponRuntime>().PickupWeapon(playerInteracting);
 }
コード例 #5
0
 public virtual void ExecuteWorldInteraction(WorldInteractionController interaction, InteractionSearcherController playerInteracting)
 {
 }
コード例 #6
0
 void LeaveClosestInteractionRange()
 {
     nearestAvailableInteraction = null;
 }