so me and some friends are making a game, and we are all new to unity. I have tried to create an animation for when i move the character to the right (ill add more later). However when the script is running, and i press ‘d’ (which i set as input ‘playerrun’), i get this error:
Parameter ‘heroStop’ does not exist.
UnityEngine.Animator:SetTrigger(String)
PlayerMovement:Update() (at Assets/PlayerMovement.cs:45)
I have set parameters called ‘heroMove’ and ‘heroStop’ and i have put them in the condition boxes of my animation section. Below are screenshots, and my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public CharacterController2D controller;
public float runSpeed = 35f;
float horizontalMove = 0f;
bool jump = false;
bool crouch = false;
public Animator anim;
public KeyCode playerrun;
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
if (Input.GetButtonDown("Jump"))
{
jump = true;
}
if (Input.GetButtonDown("Crouch"))
{
crouch = true;
}
else if (Input.GetButtonUp("Crouch"))
{
crouch = false;
}
if (Input.GetButtonDown("playerrun"))
{
GetComponent<Animator>().SetTrigger("heroMove");
}
else if (Input.GetButtonUp("playerrun"))
{
GetComponent<Animator>().SetTrigger("heroStop");
}
}
void FixedUpdate ()
{
// Move our character
controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
jump = false;
}
}
Now i have tried to restart unity as that was a common fix but it is still here. Please help me fix this…