- Home /
Question by
threepexx · Mar 26, 2020 at 10:02 PM ·
scripting problemnetworkinganimation problem
Jumping animation plays for a split second before disappearing :(
This is me making my fist game ever, and i'm totally new to coding.
Sooo, i've added all my animations in the Animator, and fixed it so they play when running and jumping. But for some reason the "Player_jump" only plays for a split second before disappearing and going back into "Player_idle". The "Player_jump" is a still image. Please help me :)
private void FixedUpdate() { int mask1 = 1 << LayerMask.NameToLayer("Bakkeoghill"); int mask2 = 1 << LayerMask.NameToLayer("Platform"); int combinedMask = mask1 | mask2;
isGrounded = Physics2D.Linecast(transform.position, groundCheck.position, combinedMask);
if (Input.GetKey("d"))
{
rb2d.velocity = new Vector2(runspeed, rb2d.velocity.y);
spriteRenderer.flipX = false;
animator.Play("Player_run");
}
else if (Input.GetKey("a"))
{
rb2d.velocity = new Vector2(-runspeed, rb2d.velocity.y);
spriteRenderer.flipX = true;
animator.Play("Player_run");
}
else
{
animator.Play("Player_idle");
rb2d.velocity = new Vector2(0, rb2d.velocity.y);
}
if (Input.GetKey("space") && isGrounded)
{
rb2d.velocity = new Vector2(rb2d.velocity.x, jumpspeed);
animator.Play("Player_jump");
}
}
Comment
Your answer
Follow this Question
Related Questions
I need help with unity navigation networking 1 Answer
MLAPI Client can't see a gameobject 0 Answers
Networked Ready check 1 Answer
Mirror : How to Sync child objects active status on join? 0 Answers