Help setting anim parameters

NodeCanvas Forums Support Help setting anim parameters

This topic contains 1 reply, has 2 voices, and was last updated by  Gavalakis 1 year ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #12090



    Is this how you check a value and set it on like an update function? In a script I would just get velocity and set the mechanim parameter on every update, and I am trying to find a proper way to do this through behavior trees. Do you think something like this should be done in trees? or should it be done through code.


    You can see in this pic, the name is exactly the same, RunSpeed. But its never set, it never changes from the behavior tree. How come?

    You must be logged in to view attached files.


    Hello and sorry for the late reply.
    It is really fine to do it within Behaviour Trees similar to what you are doing now.
    One thing I usually suggest as well for Animator Parameters, is to make use of Data Bound Variables and create a simple script with properties to bound variables to, acting as a bridge.
    For example, you can have a script like this attached on the same gameobject as the Blackboard and GraphOwner is:

    public class AnimatorParameters : MonoBehaviour{
    	private Animator _animator;
    	private Animator animator{
    		get {return _animator != null? _animator : _animator = GetComponent<Animator>();}
    	public float RunSpeed{
    		get {return animator.GetFloat("RunSpeed");}
    		set {animator.SetFloat("RunSpeed", value);}

    Then you will be able to bind a blackboard variable directly to this property and as such, whenever you set the blackboard variable, the property setter will be called whereas whenever you get the blackboard variable, the property getter will be called.
    This way, you can completely avoid using the Mecanim based Actions, but instead get/set the variable (thus the property and thus the animator parameter) quicker and easier.

    You can of course expand this script adding more properties for more parameters.
    Let me know if that helps or if you have any other questions.

    You must be logged in to view attached files.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.