WTF does this error mean
im teaching myself how to create and script animations by myself and so far so good the creating part was easy but i cant figure out what the correct scripting is to make the animation play at the right time so this errors keep showing up
An instance of type 'UnityEngine.Animation' is required to access non static member 'Stop'. An instance of type 'UnityEngine.Animation' is required to access non static member 'Play'.
and heres the lines of scripts that those errors are referencing
if(Input.GetButton("run"))
{
Animation.Play("runninganimations");
}
else
{
Animation.Stop("runninganimations");
}
Answer by Maurdekye · May 29, 2016 at 01:25 AM
It means you need to create an Animation object and call the Play and Stop functions from that object. Create an empty gameobject and add an Animation component to it. Import it into the script with a public inspector variable, and call your methods from that.
This is what your code should look like;
public Animation RunningAnimation;
void Update()
{
if (Input.GetButton("run"))
{
RunningAnimation.Play();
}
else
{
RunningAnimation.Stop();
}
}
Sorry, I don't know javascript. Although the script is simple enough that it should be easy for you to convert it. It's one public inspector variable, a single function and an if branch.