Hello everone! There some animation and sprites questions. Main Idea: I want to make smooth walk animation. I have 1) sprites for Idle 2) Sprites for walking 3) Sprite form transition state from idle to walk And also the same for jumping. I have: 1) push off ground animation 2) Jumping animation 3) Start falling 4) falling 6) end falling (touch ground) What is the best way to make it? My Variants: 1) Just some transition scheme(see the picture). There are some issues: - the idle -> start move -> run animation is ok till the moment I change direction. Character stuck in starmove animation for some reason. - Animations that are marked with blue obviously could be united in groups with enter and exit on certain animations. What is the proper way to unite them? As I understand BlendTree is best way to realize it, as you cannot select straight order. And animation layers also not good, as its purpoes to connect different animations in one object the same time (as animation of hands and legs ) 2) Select certain sprites of an animation to loop. E.g. StartMove, run and EndMove will be the same animation, but only sprites that correspond run will be included in "loop period". Is it possible to do so?
Without seeing your code it will be hard to understand why your character is stuck in the StartMove animation. As for a general comment on your animations: Why do you have so many different ones? For example, you could have an idle, and a move by combining the move with the transition (your 2. and 3.). For jump, you could only have 2, a jump and a fall. Combine your 1. and 2. for Jump into one animation and then your 3-End into one animation for falling. I think that would simplify everything a lot. So you would go from 8 animation states to 4 (idle, walk, jump and fall).
Cornysam, thanks a lot! StartMove and EndMove animations contain animation for transit between idle and run animations(I mean some specific animation when standing man start to run) . If put them into one animation they also will be looped with whole run animation. It it possible to loop certain sprites? The code: Code (CSharp): private void FixedUpdate() public float maxSpeed = 1f; private bool isFacingRight = true; private Animator anim; private bool isGrounded = false; public Transform groundCheck; private float groundRadius = 0.2f; public LayerMask whatIsGround; // Use this for initialization void Start () { anim = GetComponent<Animator>(); } // Update is called once per frame void Update () { if (isGrounded && Input.GetKeyDown(KeyCode.LeftControl)) { anim.SetBool("Ground", false); GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 600)); } } private void FixedUpdate() { var body = GetComponent<Rigidbody2D>(); isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround); anim.SetBool("Ground", isGrounded); anim.SetFloat("VSpeed", body.velocity.y); if (!isGrounded) return; float move = Input.GetAxis("Horizontal"); anim.SetFloat("Speed", Mathf.Abs(move)); body.velocity = new Vector2(move * maxSpeed, body.velocity.y); if (move > 0 && !isFacingRight) { this.Flip(); } else if (move < 0 && isFacingRight) { this.Flip(); } } private void Flip() { isFacingRight = !isFacingRight; Vector3 theScale = transform.localScale; theScale.x *= -1; transform.localScale = theScale; }
I didnt really think about that for the move animations, so my bad. I think my jump suggestion still makes sense though. For the startMove issue, it seems you set "Speed" float but it is in your animator and transitions on whether you will actually transition. Double check your transition from StartMove to run is set properly. If it appears that way, throw in a debug.log to find out what your "Speed" float in the animator actually is. If that doesnt work, check out your move value and so on until you can pinpoint where the error in transition is occuring