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
+11 -4
View File
@@ -28,14 +28,12 @@ public void EnterRoom(RoomDoor door)
/// </summary>
IEnumerator EnterRoomCoroutine(RoomDoor door)
{
float fadeDuration = 0.2f;
float fadeDuration = 0.2f; // how long to fade to/from black
float moveDuration = 0.4f; // how long to auto walk into room from the door
float fadeTime = 0;
Color blackScreenColor = Color.black;
playerController.SetCharacterControl(false);
// Don't use the Y axis to look at the door
Vector3 positionToLookAt = new Vector3(door.transform.position.x, playerController.DougBody.transform.position.y, door.transform.position.z);
playerController.DougBody.transform.LookAt(positionToLookAt);
// Play door open animation
if (door.requiresInteraction)
@@ -57,6 +55,15 @@ IEnumerator EnterRoomCoroutine(RoomDoor door)
{
blackScreenColor.a = Mathf.Lerp(1, 0, fadeTime / fadeDuration);
blackScreenObject.color = blackScreenColor;
playerController.WalkInDirection((door.linkedDoor.WalkDirection.position - playerController.transform.position).normalized);
fadeTime += Time.deltaTime;
yield return null;
}
// move character a little more
while (fadeTime < moveDuration)
{
playerController.WalkInDirection((door.linkedDoor.WalkDirection.position - playerController.transform.position).normalized);
fadeTime += Time.deltaTime;
yield return null;
}