- Home /
Question by
nubetube4321 · Jul 21, 2018 at 10:07 PM ·
c#animation2derror message
Please help me with my animations in unity 2D - c#
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:
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(); } // 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().SetTrigger("heroMove"); } else if (Input.GetButtonUp("playerrun")) { GetComponent().SetTrigger("heroStop"); } } void FixedUpdate () { // Move our character controller.Move(horizontalMove Time.fixedDeltaTime, crouch, jump); jump = false; } } ![alt text][1] ![alt text][2] Now i have tried to restart unity as that was a common fix but it is still here. Please help me fix this... [1]: /storage/temp/121287-help1.png [2]: /storage/temp/121288-help2.pngParameter 'heroStop' does not exist.
Comment
Answer by brendanperry05 · Jul 31, 2018 at 06:25 PM
Here is the information you need
https://docs.unity3d.com/ScriptReference/Animator.SetBool.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612171225im_/https://answers.unity.com/themes/thub/images/avi.jpg)