Forum rules - please read before posting.

Is it possible to drive Animator Parameters with Global Variables.

edited March 2018 in Technical Q&A
I'm trying to Drive a character's animator parameters with  AC Global variables and so far I haven't found a nice solution through action lists.

The idea is that my character has 3 float parameters, and I would like these to match 3 global variables that I am setting when using items on the player character. I plan on having many different items to set these values, so I would like a system to pass the variable directly to the animator, rather than having to do a check then set for every possible value. 
Am I missing something obvious here or will this require some code?

Comments

  • edited March 2018
    It'll need some code, but it's very simple.  See the front page of the Scripting Guide - you can read a global float variable with:

    AC.GlobalVariables.GetFloatValue (2);
    (Replace "2" with the ID number of the variable in question)

    You can set this to an animator's parameter with:

    float myFloatValue = AC.GlobalVariables.GetFloatValue (2);
    Animator myAnimator = GetComponent <Animator>();
    myAnimator.SetFloat ("MyFloatParameter", myFloatValue);

    If you place that inside the Update() method of a C# script attached to your Animator, it'll sync the values every frame.
  • This worked perfectly, thanks so much for the quick response! I've got my character set up with all sorts of equippable items now.
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.