private void HandleInput() { if (Input.GetKeyDown(KeyCode.Escape)) { SetPause(!isPaused); } if (isPaused) { return; } groundedPlayer = _characterController.isGrounded; if (groundedPlayer && playerVelocity.y < 0) { playerVelocity.y = 0f; } Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); move = transform.TransformDirection(move); _characterController.Move(move * Time.deltaTime * playerSpeed); if (Input.GetButtonDown("Jump") && groundedPlayer) { playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue); } playerVelocity.y += gravityValue * Time.deltaTime; _characterController.Move(playerVelocity * Time.deltaTime); if (Input.GetMouseButton(0)) { ExampleManager.RFC(state.id, "FireGunRFC", null); } lookCamera.isADS = Input.GetMouseButton(1); if (Input.GetKeyDown(KeyCode.R)) { Reload(); } }
protected override void Update() { base.Update(); if (!HasInit || !IsMine) { return; } groundedPlayer = controller.isGrounded; if (groundedPlayer && playerVelocity.y < 0) { playerVelocity.y = 0f; } Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); controller.Move(move * Time.deltaTime * playerSpeed); if (move != Vector3.zero) { gameObject.transform.forward = move; } // Changes the height position of the player.. if (Input.GetButtonDown("Jump") && groundedPlayer) { playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue); } playerVelocity.y += gravityValue * Time.deltaTime; controller.Move(playerVelocity * Time.deltaTime); if (Input.GetKeyDown(KeyCode.F)) { LSLog.Log("fire weapon key"); ExampleManager.RFC(state.id, "FireWeaponRFC", new object[] { new ExampleVector3Obj(transform.forward), "aWeapon" }); } }