Added Stuff

This commit is contained in:
juliuse98
2021-11-05 13:41:43 +01:00
parent 2868c0e89e
commit 908e69d4fe
21 changed files with 3143 additions and 158 deletions

View File

@@ -28,6 +28,7 @@ public class PlayerController : NetworkBehaviour
[SerializeField] private float moveGroundAngle;
public bool isGrounded;
public bool isSprinting;
private float movementSpeed;
private float velocityY = 0.0f;
private CharacterController controller;
@@ -103,15 +104,23 @@ public class PlayerController : NetworkBehaviour
{
Debug.Log("Sprint");
movementSpeed = sprintSpeed;
isSprinting = true;
}
else
{
movementSpeed = walkSpeed;
isSprinting = false;
}
Debug.Log("ggg");
//Grounded
velocityY += gravity * Time.deltaTime;
if (velocityY < 0)
{
velocityY += gravity * Time.deltaTime;
}
else
{
velocityY += gravity * 1.0f * Time.deltaTime;
}
if (isGrounded && velocityY < 0)
velocityY = 0.0f;
@@ -135,8 +144,7 @@ public class PlayerController : NetworkBehaviour
currentDir = moveDirection;
}
currentDir = currentDir + new Vector3(0, velocityY, 0);
velocity = currentDir * movementSpeed;
velocity = currentDir * movementSpeed + new Vector3(0, velocityY, 0);
controller.Move(velocity * Time.deltaTime);