-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
470 additions
and
1,095 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class PlayerController : MonoBehaviour | ||
{ | ||
[SerializeField] private float moveSpeed; | ||
[SerializeField] private Camera _camera; | ||
[SerializeField] private float speedH = 2.0f; | ||
[SerializeField] private float speedV = 2.0f; | ||
[SerializeField] private float jumpForce; | ||
|
||
private float _yaw = 0.0f; | ||
private float _pitch = 0.0f; | ||
|
||
private Rigidbody _rb; | ||
|
||
private void Start() | ||
{ | ||
_rb = GetComponent<Rigidbody>(); | ||
Cursor.lockState = CursorLockMode.Locked; | ||
Cursor.visible = false; | ||
} | ||
|
||
private void Update() | ||
{ | ||
var forward = Input.GetAxis("Vertical") * moveSpeed; | ||
var right = Input.GetAxis("Horizontal") * moveSpeed; | ||
transform.position += transform.forward * (forward * Time.deltaTime) + transform.right * (right * Time.deltaTime); | ||
|
||
var mouseRight = Input.GetAxis("Mouse X"); | ||
var mouseUp = Input.GetAxis("Mouse Y"); | ||
|
||
|
||
_yaw += speedH * Input.GetAxis("Mouse X"); | ||
_pitch -= speedV * Input.GetAxis("Mouse Y"); | ||
|
||
if (_pitch > 90) | ||
_pitch = 90; | ||
if (_pitch < -90) | ||
_pitch = -90; | ||
|
||
transform.eulerAngles = new Vector3(0.0f, _yaw, 0.0f); | ||
_camera.transform.eulerAngles = new Vector3(_pitch, _yaw, 0.0f); | ||
|
||
if (Input.GetKey(KeyCode.Space) && _rb.velocity.y == 0) | ||
_rb.velocity = new Vector3(_rb.velocity.x, jumpForce, _rb.velocity.z); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Assets/Scripts/block.cs.meta → Assets/Scripts/PlayerController.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.