- Home /
Clicking multiple objects with same tag, how to "forget" the one clicked previously...
So, I have this code of mouse navigation in my prototype.
void GetInteraction() { Ray interactionRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit interactionInfo;
if (Physics.Raycast(interactionRay,out interactionInfo, Mathf.Infinity))
{
GameObject interactedObject = interactionInfo.collider.gameObject;
if(interactedObject.tag == "Interactable Object")
{
interactedObject.GetComponent<Interactable>().MoveToInteraction(agent);
}
Now, if I click two gameobjects in a row with tag "Interactable Object" - they are both activated. So what happens, is that if I click a door, my agent walks there, and if during the walking I click another door, it starts moving there, but both door action are performed when it reaches its destination of the latter door. How can I get it to only select one at a time, so if I click the first one, it goes there, but during the path if I click a new target with same tag, it "drops" the current one clicked and starts moving to the new appointed target...
Your answer
Follow this Question
Related Questions
Physics.raycast distance not working? 1 Answer
Problem with raycasting in direction of mouse 0 Answers
2D Rigidbody Drag with Mouse 0 Answers
Raycast Object Selection 3 Answers