How can i combine Coyote Time and Jump Buffering with double jump?
Hello, I am working on a Character Controller, for this i followed a video... just like in the video I also included double Jump (https://www.youtube.com/watch?v=QGDeafTx5ug&ab_channel=Blackthornprod)
But now i wanted to also implement Coyote Time and Jump Buffering... so how can i do this ?
I followed some Tutorials for them but they all do not work with the double jump mechanic...
I dont know much about programming so I really need help..
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CharacterController : MonoBehaviour { public float speed; public float jumpForce; private float moveInput;
private bool facingRight = true;
private Rigidbody2D rb;
private bool isGrounded;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
private int extraJumps;
public int extraJumpsValue;
void Start()
{
extraJumps = extraJumpsValue;
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
if(facingRight == false && moveInput > 0)
{
Flip();
}
else if(facingRight == true && moveInput < 0)
{
Flip();
}
}
void Update()
{
if(isGrounded == true)
{
extraJumps = extraJumpsValue;
}
if(Input.GetKeyDown(KeyCode.W) && extraJumps > 0)
{
rb.velocity = Vector2.up * jumpForce;
extraJumps--;
}
else if(Input.GetKeyDown(KeyCode.W) && extraJumps == 0 && isGrounded == true)
{
rb.velocity = Vector2.up * jumpForce;
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
}
I really hope you Guys can Help me... thanks for every Answer :)
Your answer
Follow this Question
Related Questions
Double jump. Jumping after falling off a platform 1 Answer
How to double jump? i just can jump once when it touch the ground.. help me guys =D 1 Answer
What should i do i am really confused 2 Answers
"Field " " is never assigned to, and will always have it's default value null" 2 Answers
Changing game controls for android 0 Answers