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

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -