- Home /
triggering an animation on click?
i'm trying to wright some code where when you click on an object it will destroy that object and force another object to preform an animation in 2d. all i need is something that allows me to trigger an event on click the same way it would when pressing a button and i can't find that anywhere for some reason
Answer by spiked-0 · Aug 19, 2017 at 01:24 AM
@The8BitShadow Hey The8BitShadow,
Try using the built-in function for clicks in 2D or 3D: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseDown.html
void OnMouseDown()
{
// Play animation here
}
Tell me if this helps!
Your answer
Follow this Question
Related Questions
Button only works once 1 Answer
Deleting a prefab with onclick/touch 1 Answer
Two OnClicks on one button. One doesnt work all the time. 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers