Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

can't switch animation

Discussion in 'Animation' started by cookie_boy99, Aug 18, 2018.

  1. cookie_boy99

    cookie_boy99

    Joined:
    Aug 18, 2018
    Posts:
    1
    i've been trying to make a small game and i'm trying to switch between animations but no tutorials are working. anyone know how to do this? i'm using 5.6.3 thanks


    here's the script i'm using:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class gcanim : MonoBehaviour {

    Animator anim;
    int jumpHash = Animator.StringToHash("Jump");

    // Use this for initialization
    void Start () {

    anim = GetComponent<Animator>();

    }

    // Update is called once per frame
    void Update () {
    float move = Input.GetAxis("Vertical");
    anim.SetFloat("walk", move);

    if(Input.GetKeyDown(KeyCode.Space))
    {
    anim.SetTrigger(jumpHash);
    }
    }
    }

    my walk and idle animations are called walk and idle (obviously -.-)