M
M
madmaga2021-03-06 12:33:21
C++ / C#
madmaga, 2021-03-06 12:33:21

Unity how to enable animation on OnMouceDown?

Hello, I have a sprite that should animate when OnMouceDown, i.e. when clicking on the collider. And for this in the script I write

Void OnMouceDown() 
{ 
Anim. Play("MyAnim") ;
}

And this script works. When clicking on the collider
"MyAnim" is enabled. But I need some animations for my sprite that should also play on OnMouceDown. I want that when I click on the head area of ​​my sprite, the animation "MyAnim" is turned on, in the abdomen area "MyAnim2", in the area of ​​​​the arms "MyAnim3" Etc.
And for this I need to place some colliders on my sprite. And here already there is a problem. If I add several colliders and several scripts to my sprite, then unity will not know which animation to play "MyAnim" 1,2, or 3? That is, it will not know which collider is responsible for "MyAnim" and which one is for "MyAnim2". If I create an empty object for each animation and then place a script(anim.play("Myanim...")) and a collider in there. Then 2 sprites will appear on the stage. I hope the problem is clear! Thanks!!!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question