Merge branch 'main' of https://github.com/jonasbraus/Minecraft
This commit is contained in:
@@ -7,7 +7,9 @@ public class Player : MonoBehaviour
|
|||||||
{
|
{
|
||||||
//game
|
//game
|
||||||
[SerializeField] private float mouseSpeed;
|
[SerializeField] private float mouseSpeed;
|
||||||
[SerializeField] private float walkSpeed = 5;
|
[SerializeField] private float defaultSpeed = 5;
|
||||||
|
[SerializeField] private float sprintSpeed = 8;
|
||||||
|
private float walkSpeed;
|
||||||
[SerializeField] private float jumpForce;
|
[SerializeField] private float jumpForce;
|
||||||
[SerializeField] private World world;
|
[SerializeField] private World world;
|
||||||
private float playerWidth = 0.15f;
|
private float playerWidth = 0.15f;
|
||||||
@@ -39,6 +41,8 @@ public class Player : MonoBehaviour
|
|||||||
Cursor.lockState = CursorLockMode.Locked;
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
camera = GetComponentInChildren<Camera>();
|
camera = GetComponentInChildren<Camera>();
|
||||||
transform.position = GetDefaultPlayerPosition();
|
transform.position = GetDefaultPlayerPosition();
|
||||||
|
|
||||||
|
walkSpeed = defaultSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Jump()
|
private void Jump()
|
||||||
@@ -87,6 +91,16 @@ public class Player : MonoBehaviour
|
|||||||
mouseX = Input.GetAxis("Mouse X");
|
mouseX = Input.GetAxis("Mouse X");
|
||||||
mouseY = Input.GetAxis("Mouse Y");
|
mouseY = Input.GetAxis("Mouse Y");
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(KeyCode.LeftShift))
|
||||||
|
{
|
||||||
|
walkSpeed = sprintSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyUp(KeyCode.LeftShift))
|
||||||
|
{
|
||||||
|
walkSpeed = defaultSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
if (isGrounded && Input.GetButton("Jump"))
|
if (isGrounded && Input.GetButton("Jump"))
|
||||||
{
|
{
|
||||||
jumpRequest = true;
|
jumpRequest = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user