add auto-walk from the door
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user