Quantcast
Viewing all articles
Browse latest Browse all 2383

Dodgeroll script crashing game

I made a script allowing the player to dodge, but for some reason, when i pressed the button, it crashed unity, and every time i try to open it now its crashing. I can fix it externally, but i need to know what is even causing the problem. using System.Collections; using System.Collections.Generic; using UnityEngine; public class walk : MonoBehaviour { public float XRotation = 0f; float mouseSensitivity = 300f; public float YRotation = 0f; public CharacterController control; public Animator anim; public Camera cam; public Vector3 position; public float gravity = -3f; public float speed = 5f; Vector3 velocity; public bool asd; public float dashtime; public Vector3 move; public float dashspeed = 10f; public Vector3 dirright; public Vector3 dirleft; public float starttime; public bool dashright, dashleft; // Start is called before the first frame update void Start() { control = this.transform.GetComponent(); anim = this.GetComponent(); asd = true; } // Update is called once per frame void Update() { dirleft = Vector3.left; dirright = Vector3.right; while (Time.time < Time.time + starttime) { if(dashleft == true) { move = dirleft; speed = dashspeed; } if(dashright == true) { speed = dashspeed; move = transform.right; } } control.Move(velocity * Time.deltaTime); control.Move(move * speed * Time.deltaTime); velocity.y += gravity * Time.deltaTime; if (asd == true && Time.time >= Time.time + starttime) { float x = Input.GetAxis("Horizontal"); float z = Input.GetAxis("Vertical"); move = transform.right * x + transform.forward * z; } if (Input.GetKey("mouse 0") == false && Input.GetKey("mouse 1") == true) { asd = false; float MouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime; if (Input.GetKeyDown(KeyCode.Q)) { starttime = Time.time; dashleft = true; } if (Input.GetKeyDown(KeyCode.E)) { dashright = true; starttime = Time.time; } } if (Input.GetKeyUp("mouse 1")) { asd = true; } } }

Viewing all articles
Browse latest Browse all 2383

Trending Articles



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