© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
7 replies
danielggs

❔ i need some help with this please the dash is not working

private bool canDash = true;
private bool isDashing;
private float dashingPower = 24f;
private float dashingTime = 0.5f;
private float dashingCooldown = 1f;

[SerializeField] private Rigidbody2D rb;
[SerializeField] private Transform GroundCheck;
[SerializeField] private LayerMask groundlayer;
[SerializeField] private TrailRenderer tr;

// Update is called once per frame
void Update()
{
if (isDashing)
{
return;
}


if (Input.GetKeyDown(KeyCode.LeftShift) && canDash)
{
StartCoroutine(Dash());

}

}

flip();
}

private void FixedUpdate()
{
if (isDashing)
{
return;
}
rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
}


private void flip()
{
if (isFacingRight && horizontal < 0f || !isFacingRight && horizontal > 0f)
{
isFacingRight = !isFacingRight;
Vector3 localscale = transform.localScale;
localscale.x = -1f;
transform.localScale = localscale;
}
}

private IEnumerator Dash()
{
canDash = false;
isDashing = true;
float originalgravity = rb.gravityScale;
rb.gravityScale = 0f;
rb.velocity = new Vector2(transform.localScale.x dashingPower, 0f);
tr.emitting = true;
yield return new WaitForSeconds(dashingTime);
rb.gravityScale = originalgravity;
isDashing = false;
yield return new WaitForSeconds(dashingCooldown);
canDash = true;
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Need some help with lists please
C#CC# / help
3y ago
I need some help with attribute
C#CC# / help
3y ago
Hi i need help the amf function is not working
C#CC# / help
4y ago