c# - Unity; animation on prefab -


tried find kind of problem around net failed so...

here's thing - have prefab gameobject represent unit, portrait more specifically. has several scripts attached , animation component 2 animations: static , selected.
prefab instantiated, moved freely and, after placing, can clicked select it, should, aside executing bit of code, start selected animation.

using code:

    void onmousedown(){ // //some inside stuff //     if (this.getcomponent<unithandling> ().thisunit.selected)         this.animation.play("selected");     if(this.animation.isplaying ("selected"))         debug.log("animation of selection playing"); } 

i checked animation seems playing (at least debug message showing) see no animation... doing wrong?

try making animation state using mechanim, , play using this:

getcomponent<animator>().crossfade("selected", 0); 

https://docs.unity3d.com/documentation/scriptreference/animator.crossfade.html https://docs.unity3d.com/documentation/manual/mecanimanimationsystem.html


Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -