Forum rules - please read before posting.

Sprites Unity Complex- setting animator parameters with variables?

Is it possible to set a Parameter Value of a Sprites Unity Complex animation from a local or global variable?

I have an animation that is a stack of 20 cards, with 20 animation clips (1 for each card). I'm using an int parameter on the animator to choose which card to display. I'd like to set the value of my int parameter by replacing with a variable but can't figure out how to do that.

In the OBJECT-ANIMATE action I can manually make the change with "Set as Value:" but I'm not able to use a Replacement Token (of my variable I want to use) in that field.

Any suggestions on how to do this?


  • You can do it by using parameters as an interim.

    Create an "Integer" parameter in your ActionList, and an ActionList: Set parameter Action. Check Change own?, select the parameter, set New value is to Copied From Global Variable, and select the variable.

    In your Object: Animate Action, you can then override the Set as value field with your parameter, which in turn is set from the variable.

    You can also do it via script:

    public Animator myAnimator;
    public int variableID;
    public string parameterName = "MyParameter";
    public void UpdateFromVariable ()
        int myInt = AC.LocalVariables.GetIntegerValue (variableID);
        myAnimator.SetInteger (parameterName, myInt);

    Placing that inside a script class, attaching it to a GameObject, and configuring the Inspector would allow you to run its UpdateFromVariable method via the Object: Call event Action. Replace "Local" with "Global" to copy from a Global variable.

  • Thanks Chris. I'm not sure I've set this up correctly, as I'm not able to select my actionlist's Integer Parameter in the "Set As Value" field. I can only manually enter a value.

    See the image here.

  • edited March 18

    My apologies - I tested my explanation using the WIP AC release. This feature is included as part of that.

    This'll be possible when AC v1.67.0 is out - which should be this week or next. PM me if you would like to be involved in testing.

  • No worries! I can wait for the next version of AC to be released. Thanks!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.