I’m having trouble with what seems like it should be a very simple problem. I can’t seem to find a simple explanation or tutorial showing how to make an object respond when clicked on. I have a C# script that plays an animation when the left mouse button is clicked, but I don’t know how to make it only play when the object itself is clicked, not just any place on the screen. I know this must be simple, but I have absolutely zero experience in coding anything, so I really need a simple explanation that I could apply to other objects and scripts as well. Here is my current script:
using UnityEngine;
using System.Collections;
public class Shrinkscript : MonoBehaviour {
// Update is called once per frame
void Update () {
if (Input.GetMouseButton(0))
{
animation.Play("Shrink");
}
}
}
Any help is much appreciated!