I got mixed it all and got confused.
What i want to do is when i click the right mouse button don’t call the GetInteraction(); function when i click on the left mouse button call it.
Like a switch/pause button. Click on right will stop calling it click on left will keep calling it. I tried to use the toMove bool variable but messed it all.
void Update() {
if (Input.GetMouseButtonDown(0) && to Move == false &&
!UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject)
{
toMove = true;
}
if (Input.GetMouseButtonDown(1) && toMove == true)
{
toMove = false;
}
if (toMove == true)
{
GetInteraction();
}
}
I’m not actually sure what GetInteraction() does or is supposed to do, but hopefully it’s something like this that you are looking for? If this doesn’t work could you provide if GetInteraction(); is something you are trying to call every frame whentoMove = true or something you only want to call when it’s true and you are right-clicking.
I’m not sure how exatly you want this to work. Should GetInteraction() only be called while the left button is pressed? Or do you want GetInteraction() to be continuously called after a left click until you click right?
This will call GetInteraction() as long you hold left and the cursor is not over an object: