I’m trying to make walk animation. But when I try to change animation idle to walk, ıt doesn’t work. It says 'Parameter “Walk” doesn’t exist’but I added parameter and script works. I can manually change parameter and it works(walk animation is playing). But when I try to change via script, ıt doesn’t work.
Here are codes
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Controller : MonoBehaviour
{
private Rigidbody rb;
private float xPos;
Vector3 playerMovement;
[SerializeField] Animator anim;
private void Awake() => rb = GetComponent<Rigidbody>();
private void Start()
{
xPos = transform.position.x;
}
// Update is called once per frame
void Update()
{
Move();
}
private void Move()
{
float mH = Input.GetAxis("Horizontal");
playerMovement = new Vector3(0, 0, mH);
rb.AddForce(playerMovement * 2f);
anim.SetFloat("Walk", 1);
transform.position = new Vector3(xPos, transform.position.y, transform.position.z);
}
}