private void Update() { timeSinceLastShot += Time.deltaTime; mousePos = cam.ScreenToWorldPoint(Input.mousePosition); if (Input.GetMouseButtonDown(0)) { gun.Shoot(); timeSinceLastShot = 0f; } }
void HandleShooting() { // Shoot bullets bool holding = Input.GetButton("Shoot"); bool click = Input.GetButtonDown("Shoot"); if ((holding && !gunController.GunStats.IsSemiAuto) || click) { gunController.Shoot(); //if (gunController.BulletShot) //{ // SoundManager.PlaySound(Sounds.PlayerGunshot); // events.FireEvent(new WeaponFired()); //} } }
void Update() { //if (Input.GetKeyDown(KeyCode.UpArrow)) Move(Vector2Int.up); //else if (Input.GetKeyDown(KeyCode.DownArrow)) Move(Vector2Int.down); if (Input.GetKeyDown(KeyCode.LeftArrow)) { Move(Vector2Int.left); } else if (Input.GetKeyDown(KeyCode.RightArrow)) { Move(Vector2Int.right); } else if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl)) { gun.Shoot(); } }
void Update() { if (Input.GetButtonDown("Fire1")) { if (ammo > 0 && !waiting) { gun.Shoot(); Shot(); waiting = true; } } if (waiting && timer < shootTime) { timer += 1 * Time.deltaTime; } else { waiting = false; timer = 0; } }
// Update is called once per frame void Update() { playerMoving = false; if (Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f) { //transform.Translate (new Vector3 (Input.GetAxisRaw ("Horizontal") * currentMoveSpeed * Time.deltaTime, 0f , 0f)); myRigidbody.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * currentMoveSpeed, myRigidbody.velocity.y); playerMoving = true; lastMove = new Vector2(Input.GetAxisRaw("Horizontal"), 0f); } if (Input.GetAxisRaw("Vertical") > 0.5f || Input.GetAxisRaw("Vertical") < -0.5f) { //transform.Translate (new Vector3 (0f, Input.GetAxisRaw ("Vertical") * currentMoveSpeed * Time.deltaTime, 0f)); myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, Input.GetAxisRaw("Vertical") * currentMoveSpeed); playerMoving = true; lastMove = new Vector2(0f, Input.GetAxisRaw("Vertical")); } if (Input.GetAxisRaw("Horizontal") < 0.5f && Input.GetAxisRaw("Horizontal") > -0.5f) { myRigidbody.velocity = new Vector2(0f, myRigidbody.velocity.y); } if (Input.GetAxisRaw("Vertical") < 0.5f && Input.GetAxisRaw("Vertical") > -0.5f) { myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, 0f); } if (Mathf.Abs(Input.GetAxisRaw("Horizontal")) > 0.5f && Mathf.Abs(Input.GetAxisRaw("Vertical")) > 0.5f) { currentMoveSpeed = moveSpeed * 0.66f; } else { currentMoveSpeed = moveSpeed; } if (Input.GetButtonDown("Jump") && GameMaster.Instance.dash && Time.time - lastDash >= 0.5f) { Vector2 target = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 direction = target - new Vector2(transform.position.x, transform.position.y); dashScript.Dash(dashDistance, dashSpeed, direction.normalized, dashMask); lastDash = Time.time; } if (Input.GetButtonDown("Fire1")) { gunScript.Shoot(); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } anim.SetFloat("MoveX", Input.GetAxisRaw("Horizontal")); anim.SetFloat("MoveY", Input.GetAxisRaw("Vertical")); anim.SetBool("PlayerMoving", playerMoving); anim.SetFloat("LastMoveX", lastMove.x); anim.SetFloat("LastMoveY", lastMove.y); }