Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Need help with dashing code

$
0
0
I have followed this tutorial https://www.youtube.com/watch?v=lckH-nJi2j8&t=193s and it's saying ![alt text][1] Here's my code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMove : MonoBehaviour { private Rigidbody2D rb; private BoxCollider2D bc; private static bool isRunning; private static bool isMoving; private static bool isDashing; private static bool isOnWall; private static bool cooldown; private static bool jumpCooldown; private float time = 2; private float dashingspeed = 14; private Vector2 dashingDir; // Start is called before the first frame update private void Start() { rb = GetComponent(); bc = GetComponent(); cooldown = false; } // Update is called once per frame private void Update() { float dirX = Input.GetAxisRaw("Horizontal"); rb.velocity = new Vector2(dirX * 4f, rb.velocity.y); isMoving = true; float dirY = Input.GetAxisRaw("Vertical"); if (Input.GetKey("left ctrl")) isRunning = true; else { isRunning = false; } if (Input.GetKeyDown("left shift")) isDashing = true; else { isDashing = false; } if (Input.GetButtonDown("Jump")) { rb.velocity = new Vector2(rb.velocity.x, 8f); } if (isRunning == true && isMoving == true) { rb.velocity = new Vector2(dirX * 6f, rb.velocity.y); } if (isDashing == true && cooldown == false) { cooldown = true; dashingDir = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); isDashing = false; if (dashingDir == new Vector2(0,0)) { dashingDir = new Vector2(transform.localScale.x, 0); } StartCoroutine(StopDashing()); } if (isDashing == true) { rb.velocity = dashingDir.normalized * dashingspeed; return; } if (IsGrounded()) { cooldown = false; } IEnumerator StopDashing(); { yield return new WaitForSeconds(time); cooldown = false; } } } [1]: /storage/temp/199070-errors-with-my-dash-code.png

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>