danielggs
danielggs
CC#
Created by danielggs on 12/27/2022 in #help
❔ 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;
8 replies