Hello I recently got my dash to work but then i had trouble with the players jumps. It barely jumps and is glitching so hard. OBS my jumps were really good before i made the dash!!! Here’s my jump code and dash code.
bool isJumping;
public float jumpForce;
void FixedUpdate() {
if (Input.GetKey(KeyCode.W) == true && !isJumping)
{
isJumping = true;
myRigidbody.AddForce(new Vector2(myRigidbody.velocity.x, jumpForce));
}
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Ground"))
{
isJumping = false;
myRigidbody.velocity = Vector2.zero;
}
}
Here’s my dash code:
public float dashSpeed;
private float dashTime;
public float startDashTime;
void Start()
{
dashTime = startDashTime;
}
void FixedUpdate() {
if (dashTime <= 0)
{
dashTime = startDashTime;
myRigidbody.velocity = Vector3.zero;
}
else
{
dashTime -= Time.deltaTime;
if (Input.GetKeyDown(KeyCode.Space) == true && Input.GetKeyDown(KeyCode.D) == false && !facingRight)
{
myRigidbody.velocity = Vector3.left * dashSpeed;
}
else if (Input.GetKeyDown(KeyCode.Space) == true && Input.GetKeyDown(KeyCode.A) == false && facingRight)
{
myRigidbody.velocity = Vector3.right * dashSpeed;
}
}
},