- Home /
Question by
BraniDev · Mar 01, 2020 at 10:54 PM ·
jumpinganimationsdouble jump
Please Help me fix my code (jumping animation playing once)
please help me fix my code (i know is messy it is my first time) i was changing my code from PC > mobile and these errors i get : jump only once should be twice and play animation only for first time
public void JumpingStuff()
{
if (_grounded == true)
{
playerAS.clip = playerjump2;
playerAS.Play();
extraJumps = extraJumpsValue;
m_Jump = true;
//here allow to end the animation if some time was passed
if (!hasJumped && m_Animator.GetBool("Jumping"))
{
m_Animator.SetBool("Jumping", false);
}
}
//(Input.GetKeyDown(KeyCode.Space) && extraJumps > 0)
// PC
if
(extraJumps > 0)
{
rb.velocity = Vector2.up * jumpForce;
extraJumps--;
if (m_Jump == true)
m_Animator.SetBool("Jumping", true);
playerAS.clip = playerjump;
playerAS.Play();
//Debug.Log("playing jumping animation");
//here your player has began the jump
if (!hasJumped)
{
hasJumped = true;
StartCoroutine("WaitBitAfterJump");
//Play sound when he jump
//playerAS.PlayOneShot(playerjump);
}
}
//(Input.GetKeyDown(KeyCode.Space) && extraJumps == 0 && _grounded == true)
//PC
else if (extraJumps == 0 && _grounded == true)
{
rb.velocity = Vector2.up * jumpForce;
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
m_Animator.SetBool("Jumping", false);
Debug.Log("I am Jumping");
}
}
Comment
Your answer
Follow this Question
Related Questions
Double Jump Not working 2 Answers
How can I stop my player from jumping after double jumps? My player consistently jumping. 2 Answers
Triple jumping instead of double 2 Answers
2D double jump doesn't work. 2 Answers
Possible bug (Twitchy Animations) with Unity 5.3.4f1 & Mixamo characters?!? 0 Answers