- Home /
[ex2D] How to link an animation from another class
Hello,
I'm just beginning Unity and I have a few problem with ex2D. I have an object "knight" and into him I play an animation :
public exSpriteAnimation animtest;
void Start () {
animtest.Play ( "anim_run" );
No probem here but I have another object into knight (sword) and knight is the parent of sword.
I want to play a different knight animation when my object sword collides another object like that :
void OnTriggerEnter(Collider testcollider){
if (testcollider.gameObject.name == "monster"){
knight.animtest.Play ( "anim_run_hit" ); // THIS IS MY BAD LANE :D
}
I don't know how to play an animation from another class...
Maybe you can help me :) (sorry for my bad english)
Thanks in advance !
Comment
Could you post the error message you got for the problematic line? It could be simply missing of a direct reference to the sprite animation component.