Well… I’m trying to make an object play an animation when i’m looking at it (with raycasts and range check). All goes well and is detected… But the animation is not played.
Went through some testing and well… It seems that this does work:
void OnGUI()
{
if(GUI.Button(new Rect(0f, 0f, 100f, 20f), "Open"))
{
GameObject.FindGameObjectWithTag("STOLIK").animation.Play("idle");
}
}
Meanwhile this does not :
public GameObject target;
void OnGUI()
{
if(GUI.Button(new Rect(0f, 0f, 100f, 20f), "Open"))
{
target.animation.Play("idle");
}
}
And… yes. I’m selecting the correct gameobject in the editor.
What am I doing wrong?