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
+17 -3
View File
@@ -67,9 +67,11 @@ public void EnterSceneDoor(string scene, int door)
private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
{
isTransitioningScenes = true;
playerController.SetCharacterControl(false);
// Fade to black
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;
@@ -95,10 +97,10 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
// Make sure screen is black in new scene
blackScreen.color = blackScreenColor;
SceneDoor door = GameSceneManager.Instance.GetDoorWithId(doorId);
if (playerController != null && GameSceneManager.Instance != null)
{
SceneDoor door = GameSceneManager.Instance.GetDoorWithId(doorId);
if (door != null)
{
playerController.CharacterControllerMove(door.gameObject.transform.position - playerController.transform.position);
@@ -112,11 +114,23 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
blackScreenColor.a = Mathf.Lerp(1, 0, fadeTime / fadeDuration);
blackScreen.color = blackScreenColor;
fadeTime += Time.deltaTime;
playerController.WalkInDirection((door.WalkDirection.position - playerController.transform.position).normalized);
yield return null;
}
// move character a little more
while (fadeTime < moveDuration)
{
playerController.WalkInDirection((door.WalkDirection.position - playerController.transform.position).normalized);
fadeTime += Time.deltaTime;
yield return null;
}
fadeTime = 0;
isTransitioningScenes = false;
playerController.SetCharacterControl(true);
}
/// <summary>