Property Bindings

Property bindings will map your variable value to a C# property in your own script. Let’s say that you have the following script:

public class Health : MonoBehaviour
{
    [Tooltip("The starting health value")]
    [SerializeField] protected float m_StartHealth = 100;

    private float m_HealthAmount;

    public float HealthAmount { get => m_HealthAmount; set => m_HealthAmount = value; }
}

Within Behavior Designer you can click on the “>” icon to the right of the Shared Variable and “Enable Property Binding” to map the Shared Variable to the C# property:

With this mapping when you access the Value property it will call the getter or setting of the property that it is bound to. This makes it extremely convenient to ensure you are using the same variable value within the behavior tree and outside of the behavior tree. For performance reasons this feature requires both a getter and a setter of the property, and it does not work on fields.