add auto-walk from the door

This commit is contained in:
2026-03-07 11:33:41 -06:00
parent 13a1e24099
commit 94fa81168d
7 changed files with 270 additions and 20 deletions
+23
View File
@@ -109,6 +109,29 @@ public void CharacterControllerMove(Vector3 movement)
characterController.Move(movement);
}
/// <summary>
/// Auto-walk the character in the specified direction. Uses character's walk
/// speed and camera rotation (per-frame)
/// </summary>
public void WalkInDirection(Vector3 direction)
{
Vector3 forwardDir = direction;
forwardDir.y = 0; // don't move on the y axis
if (cameraController != null)
{
// re-matrix the rotation direction so movement is consistent no matter what
// the camera rotation is
Matrix4x4 matrix = Matrix4x4.Rotate(Quaternion.Euler(0, cameraController.playerCamHome.rotation.eulerAngles.y, 0));
forwardDir = matrix.MultiplyPoint3x4(forwardDir);
}
forwardDir *= walkSpeed;
characterController.Move(forwardDir * Time.deltaTime);
}
/// <summary>
/// Detect input for digging (will eventually be tool agnostic)
/// </summary>