add sprint, basic projection for shovel dig radius
This commit is contained in:
@@ -142,6 +142,14 @@ public bool InSceneTransition()
|
||||
return Instance.isTransitioningScenes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the blackscreen object reference
|
||||
/// </summary>
|
||||
public Image GetBlackScreen()
|
||||
{
|
||||
return Instance.blackScreen;
|
||||
}
|
||||
|
||||
#region Storybool Save/Load
|
||||
public void SaveStoryBools(ref StoryboolSaveData data)
|
||||
{
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
// Handle room and scene transitions
|
||||
public class TeleportHandler : MonoBehaviour
|
||||
{
|
||||
public Image blackScreenObject;
|
||||
Image blackScreenObject;
|
||||
PlayerController playerController;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
blackScreenObject = GameManager.Instance.GetBlackScreen();
|
||||
playerController = GetComponent<PlayerController>();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ public class PlayerController : MonoBehaviour
|
||||
public GameObject DougBody;
|
||||
public Shovel Shovel;
|
||||
public float walkSpeed;
|
||||
public float sprintMultiplier = 1.5f;
|
||||
public float gravity = 10;
|
||||
|
||||
float digTime = 0.9f;
|
||||
@@ -18,7 +19,8 @@ public class PlayerController : MonoBehaviour
|
||||
private CameraController cameraController;
|
||||
private Vector3 moveDir;
|
||||
private bool hasControl = true; // set this to false if we want to stop reading player inputs
|
||||
|
||||
private bool isSprinting = false;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
@@ -43,7 +45,7 @@ void Update()
|
||||
ApplyWalk();
|
||||
|
||||
// TODO: This is just for testing, remove or clean up if used
|
||||
if (Input.GetKeyDown(KeyCode.LeftShift))
|
||||
if (Input.GetKeyDown(KeyCode.Q))
|
||||
{
|
||||
cameraController.RotateCam();
|
||||
}
|
||||
@@ -55,10 +57,26 @@ void Update()
|
||||
}
|
||||
}
|
||||
|
||||
CheckSprint();
|
||||
ApplyGravity();
|
||||
DoMovement();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if shift is being held, isSprinting is true if it is
|
||||
/// </summary>
|
||||
private void CheckSprint()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
isSprinting = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isSprinting = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply walking inputs to moveDir
|
||||
/// </summary>
|
||||
@@ -86,11 +104,14 @@ void ApplyWalk()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply gravity to moveDir
|
||||
/// Apply gravity and speed to moveDir
|
||||
/// </summary>
|
||||
void ApplyGravity()
|
||||
{
|
||||
moveDir *= walkSpeed;
|
||||
if (isSprinting)
|
||||
moveDir *= (walkSpeed * sprintMultiplier);
|
||||
else
|
||||
moveDir *= walkSpeed;
|
||||
|
||||
if (!characterController.isGrounded)
|
||||
{
|
||||
@@ -123,6 +144,7 @@ public void WalkInDirection(Vector3 direction)
|
||||
{
|
||||
Vector3 forwardDir = direction;
|
||||
forwardDir.y = 0; // don't move on the y axis
|
||||
|
||||
forwardDir *= walkSpeed;
|
||||
|
||||
characterController.Move(forwardDir * Time.deltaTime);
|
||||
|
||||
Reference in New Issue
Block a user