CodeBlanks Logo Icon CodeBlanks

Parameters

Learn to trigger transitions with Bool, Trigger and Float parameters.

Bool, Float, and Trigger Parameters

Animator Controller parameters control transition conditions using different data types. Bool represents two-state values, Float represents numeric values, and Trigger represents one-time events. Choose the parameter type that matches the animation behavior.

// Bool: isGrounded
// Float: verticalSpeed
// Trigger: takeDamage

Connecting Parameters to Transition Conditions

You can use parameters created in the Parameters tab of the Animator window as Transition conditions. For example, a verticalSpeed value falling below a certain threshold can trigger a transition to a falling animation. Multiple conditions can also be defined for the same transition.

// verticalSpeed < 0
// isGrounded == false

Practice Set the Vertical Speed Parameter

Set the value of the Float parameter named verticalSpeed on the Animator component. Use a vertical speed value and then print the assigned value to the console.

Starter code

Player.cs
using UnityEngine;

public class VerticalSpeed : MonoBehaviour
{
    public Animator animator;

    void Update()
    {
        
    }
}

Sample solution

Player.cs
using UnityEngine;

public class VerticalSpeed : MonoBehaviour
{
    public Animator animator;
    public float currentVerticalSpeed;

    void Update()
    {
        animator.SetFloat("verticalSpeed", currentVerticalSpeed);
        Debug.Log("Dikey hız güncellendi: " + currentVerticalSpeed);
    }
}

Expected output

Dikey hız güncellendi: 2

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which parameter type is suitable for tracking whether a character is touching the ground?

  • AnimationClip
  • Bool Correct answer
  • Float
  • Trigger

Explanation: Bool is used to track whether a character is grounded as true or false.

2 Event Parameter

Question
Tek seferlik bir animasyon olayını temsil etmek için ____ parametresi kullanılır.
Answer
Tek seferlik bir animasyon olayını temsil etmek için Trigger parametresi kullanılır.

Explanation: Trigger is designed to activate one-time animation events.

3 Match Parameter Use Cases

Term Meaning
isGrounded Indicates if character is grounded
verticalSpeed Stores vertical movement speed
takeDamage Triggers a damage animation event
Threshold Boundary value for a numeric condition

All lessons in Intermediate