Hello everyone , I'm creating a among us game and i have created 2x animations idle and run .. the problem is when i press play i find that 2x animations works together when i move and the run animation under idle animation.. check the photo .. i don't know whats wrong !
here it is and the source is Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class CharacterController : MonoBehaviour { Rigidbody RB; Transform Player; [SerializeField] InputAction WASD; Vector2 movementInput; [SerializeField] float moveSpeed; Animator Anim; private void OnEnable() { WASD.Enable(); } private void OnDisable() { WASD.Disable(); } void Start() { RB = GetComponent<Rigidbody>(); Player = transform.GetChild(0); Anim = GetComponent<Animator>(); } void Update() { movementInput = WASD.ReadValue<Vector2>(); if(movementInput.x != 0) { Player.localScale = new Vector2(Mathf.Sign(movementInput.x), 1); } Anim.SetFloat("Speed", movementInput.magnitude); } private void FixedUpdate() { RB.velocity = movementInput * moveSpeed; } }
Maybe I am misunderstanding your issue. Are you saying that both the Idle and Run animations are occuring at the same time? Your first image is unclear to me
yes , Idle is above run when i move or testing the animation before i try in game mode.. check the video
Ooooh okay that appears to make sense to me now. When you were on the Run animation in the animation window, it looked like you had two sprites on top of each other. So go into the animation for run and make sure that only one sprite is on each frame. If that isnt clicking with you, i would just remake your run animation and make sure you are only putting one Run sprite at each frame. Recreating the run animation should take less than 2 minutes since it appears to be 5 sprites or less.
i remade it with only 1 sprite each frame , im sure about that and i still have the problem... check the photos
That is bizarre. Maybe redo your transitions in the Animator window. Also, press play and look at the Animator window to see which animation is technically running. I am not sure what it is but i think its purely an issue with the Animator and your transitions, you might just have to mess around with them. I wish i could be more help.
thanks for trying to help me brother , maybe i will change my unity to 2020 , because im sure nothing wrong
Ehh, before you try that, just make a new scene, a new animator and new animations. In my opinion that is easier than installing a different version
Hmmm very weird as it seems everything is set up properly. Looking at your code more, maybe it has something to do with your Vector2 movementSpeed and using magnitude. Im sorry I havent been any help. If it still doesnt work, id try to rework your movement code. This Brackey's video is one of the best in my opinion: Good luck mate!