❔ 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;
4 Replies
debug with Debug.Log method
see whats being called and whats not being called
i dont think ur code will compile with that code anyway
u either want
transform.localScale.x
or dashingPower
as the first argument$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.