Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackGameDev/status/853881150896447488
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added a tag
Source Link
FShiwani
  • 43
  • 1
  • 7

So I'm trying to have my script pause an animation when the user clicks. Here's what I have so far:

I defined the animation up at the top

public Animation anim;

and then further down,

    void Update () {
        if (Input.GetMouseButtonDown(0))
        {
            anim["myAnimation"].speed = 0.0f;
        }
    
    }

Code gives no error, however in Unity I have a GameController object to which this script is attached to. The gamecontroller object has a vacant field into which I drop my animation to. The issue is that when I try and drag and drop my animation or try to place it into that field, nothing happens, I keep getting the error down at the bottom saying that "The variable anim of GameController has not been assigned." How do I go about assigning myAnimation to the variable anim?

Issue

When I try and drag and drop my animation file to this, nothing happens. This is under the GameController script which I assigned to a GameController object.

So I'm trying to have my script pause an animation when the user clicks. Here's what I have so far:

I defined the animation up at the top

public Animation anim;

and then further down,

    void Update () {
        if (Input.GetMouseButtonDown(0))
        {
            anim["myAnimation"].speed = 0.0f;
        }
    
    }

Code gives no error, however in Unity I have a GameController object to which this script is attached to. The gamecontroller object has a vacant field into which I drop my animation to. The issue is that when I try and drag and drop my animation or try to place it into that field, nothing happens, I keep getting the error down at the bottom saying that "The variable anim of GameController has not been assigned." How do I go about assigning myAnimation to the variable anim?

So I'm trying to have my script pause an animation when the user clicks. Here's what I have so far:

I defined the animation up at the top

public Animation anim;

and then further down,

    void Update () {
        if (Input.GetMouseButtonDown(0))
        {
            anim["myAnimation"].speed = 0.0f;
        }
    
    }

Code gives no error, however in Unity I have a GameController object to which this script is attached to. The gamecontroller object has a vacant field into which I drop my animation to. The issue is that when I try and drag and drop my animation or try to place it into that field, nothing happens, I keep getting the error down at the bottom saying that "The variable anim of GameController has not been assigned." How do I go about assigning myAnimation to the variable anim?

Issue

When I try and drag and drop my animation file to this, nothing happens. This is under the GameController script which I assigned to a GameController object.

Source Link
FShiwani
  • 43
  • 1
  • 7

Can't assign animation to animation variable declared in script Unity2D

So I'm trying to have my script pause an animation when the user clicks. Here's what I have so far:

I defined the animation up at the top

public Animation anim;

and then further down,

    void Update () {
        if (Input.GetMouseButtonDown(0))
        {
            anim["myAnimation"].speed = 0.0f;
        }
    
    }

Code gives no error, however in Unity I have a GameController object to which this script is attached to. The gamecontroller object has a vacant field into which I drop my animation to. The issue is that when I try and drag and drop my animation or try to place it into that field, nothing happens, I keep getting the error down at the bottom saying that "The variable anim of GameController has not been assigned." How do I go about assigning myAnimation to the variable anim?