I know theres a way to check if two object collide. But how could i tell if the mouse clicks on the object?
There is a function that will be called when you click on a gameobject. Have a look at this section of the documention:
Thank how would you check the cliked on tag?
bump
You’ll have to do a raycast from the mouse screen position.
The OnMouseDown() method is called when you click on an object. Just put whatever you want inside the medthod and it will happen when you click on it. For example:
void OnMouseDown()
{
Debug.Log("Clicked");
if (gameObject.tag == "whatever")
{
Debug.Log("Tag is equal to: " + gameObject.tag);
}
}
Everytime you click on the object that this script is attached to it will print: Clicked
you can check it’s tag inside the code blocks.