Search Unity

Question Is there any way to set an animation as the default state from the code?

Discussion in 'Animation' started by jrtux999, Dec 31, 2021.

  1. jrtux999

    jrtux999

    Joined:
    Sep 30, 2021
    Posts:
    1
    I'm trying to make a game and I need to change the default animation for another from the code. Is there any way to do this?

    upload_2022-1-1_0-52-40.png

    In the code I have this:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class WaterBucketController : MonoBehaviour {

    public Animator animator;
    private void OnTriggerEnter2D(Collider2D collision) //WHEN U TOUCH THE WATER BUCKET IT GETS DESTROYED AND IT CHANGES THE DEFAULT ANIMATION (WHAT I'M TRYING TO DO)
    {
    Destroy(gameObject, 0.1f);
    }
    }


    Thank you!