add auto-walk from the door
This commit is contained in:
@@ -748,6 +748,7 @@ MonoBehaviour:
|
||||
DoorId: 0
|
||||
SceneToLoad: TestScene2
|
||||
IdOfCorrespondingDoor: 0
|
||||
WalkDirection: {fileID: 1326747835}
|
||||
--- !u!65 &127908879
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -777,13 +778,13 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 127908877}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
||||
m_LocalPosition: {x: -0.47499996, y: 34.3, z: 0.00000012626319}
|
||||
m_LocalRotation: {x: -0, y: 0.9998919, z: -0, w: -0.01470473}
|
||||
m_LocalPosition: {x: -0.281, y: 34.299995, z: 0.001}
|
||||
m_LocalScale: {x: 1.1708915, y: 69.57974, z: 1.1708915}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 902781402}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 181.685, z: 0}
|
||||
--- !u!1 &130527586
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1023,7 +1024,7 @@ Transform:
|
||||
m_GameObject: {fileID: 151657444}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
||||
m_LocalPosition: {x: -0.47499996, y: 34.3, z: 0.00000012626319}
|
||||
m_LocalPosition: {x: -0.259, y: 34.3, z: 0.029}
|
||||
m_LocalScale: {x: 1.1708915, y: 69.57974, z: 1.1708915}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@@ -1043,6 +1044,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::RoomDoor
|
||||
linkedDoor: {fileID: 299619812}
|
||||
requiresInteraction: 0
|
||||
WalkDirection: {fileID: 615859200}
|
||||
doorAnimator: {fileID: 0}
|
||||
openDoor: {fileID: 0}
|
||||
closeDoor: {fileID: 0}
|
||||
@@ -1550,6 +1552,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::RoomDoor
|
||||
linkedDoor: {fileID: 151657446}
|
||||
requiresInteraction: 1
|
||||
WalkDirection: {fileID: 1692969915}
|
||||
doorAnimator: {fileID: 1966866173}
|
||||
openDoor: {fileID: 7400000, guid: 590cc63b33bbdf34cb9f8d8ed097b12d, type: 2}
|
||||
closeDoor: {fileID: 7400000, guid: 0651f9c0ca66bb140b1209461bc72ee2, type: 2}
|
||||
@@ -2192,6 +2195,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 151657445}
|
||||
- {fileID: 615859200}
|
||||
m_Father: {fileID: 2075083864}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 45, z: 0}
|
||||
--- !u!65 &441147621
|
||||
@@ -2718,6 +2722,7 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1692969915}
|
||||
- {fileID: 1735546793}
|
||||
- {fileID: 299619810}
|
||||
- {fileID: 1966866169}
|
||||
@@ -2891,6 +2896,37 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 589087811}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &615859199
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 615859200}
|
||||
m_Layer: 0
|
||||
m_Name: WalkDirection
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &615859200
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 615859199}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0.38268343, z: -0, w: 0.92387956}
|
||||
m_LocalPosition: {x: -1.286, y: 0.06957974, z: 0.002}
|
||||
m_LocalScale: {x: 1.1708915, y: 69.57974, z: 1.1708915}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 441147620}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &640727376
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3554,6 +3590,37 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 759119782}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &774104015
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 774104016}
|
||||
m_Layer: 0
|
||||
m_Name: RoomDirection
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &774104016
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 774104015}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: -0.36247146, z: -0, w: -0.93199486}
|
||||
m_LocalPosition: {x: -1.136, y: 0, z: -0.04}
|
||||
m_LocalScale: {x: 1.1537356, y: 69.57974, z: 1.1885651}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1055802463}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &813193271
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3726,6 +3793,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 127908880}
|
||||
- {fileID: 1326747835}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 136.998, z: 0}
|
||||
--- !u!65 &902781403
|
||||
@@ -4313,6 +4381,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1072227175}
|
||||
- {fileID: 774104016}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 317.496, z: 0}
|
||||
--- !u!65 &1055802464
|
||||
@@ -4426,6 +4495,7 @@ MonoBehaviour:
|
||||
DoorId: 1
|
||||
SceneToLoad: TestScene2
|
||||
IdOfCorrespondingDoor: 1
|
||||
WalkDirection: {fileID: 774104016}
|
||||
--- !u!65 &1072227174
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4445,8 +4515,8 @@ BoxCollider:
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 0.4, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Size: {x: 1, y: 1, z: 0.4}
|
||||
m_Center: {x: 0, y: 0, z: 0.15}
|
||||
--- !u!4 &1072227175
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4455,13 +4525,13 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1072227172}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
||||
m_LocalPosition: {x: -0.47499996, y: 34.3, z: 0.00000012626319}
|
||||
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: -0.475, y: 34.299995, z: -0.000000010521932}
|
||||
m_LocalScale: {x: 1.1708915, y: 69.57974, z: 1.1708915}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1055802463}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
|
||||
--- !u!1 &1114011169
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -5316,6 +5386,37 @@ MeshFilter:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1316688875}
|
||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &1326747834
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1326747835}
|
||||
m_Layer: 0
|
||||
m_Name: RoomDirection
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1326747835
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1326747834}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0.93041223, z: 0, w: 0.3665149}
|
||||
m_LocalPosition: {x: -0.965, y: 0, z: 0.087}
|
||||
m_LocalScale: {x: 1.157109, y: 69.57974, z: 1.1850055}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 902781402}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1336310661
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -6448,6 +6549,37 @@ Transform:
|
||||
- {fileID: 330585546}
|
||||
m_Father: {fileID: 101519019}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1692969914
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1692969915}
|
||||
m_Layer: 0
|
||||
m_Name: WalkDirection
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1692969915
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1692969914}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0.924, y: -0.34143996, z: -0.097}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 562959766}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1703788694
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -256,6 +256,7 @@ MonoBehaviour:
|
||||
DoorId: 0
|
||||
SceneToLoad: SampleScene
|
||||
IdOfCorrespondingDoor: 0
|
||||
WalkDirection: {fileID: 134307099}
|
||||
--- !u!65 &127908879
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -429,6 +430,37 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 130527586}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &134307098
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 134307099}
|
||||
m_Layer: 0
|
||||
m_Name: RoomDirection
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &134307099
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 134307098}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: 0.9999906, z: -0, w: -0.004342109}
|
||||
m_LocalPosition: {x: -0.852, y: 0, z: -0.003}
|
||||
m_LocalScale: {x: 1.1537608, y: 69.57974, z: 1.1885278}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 902781402}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &143070239
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2599,11 +2631,12 @@ Transform:
|
||||
m_GameObject: {fileID: 902781401}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: 0.93041223, z: -0, w: 0.3665149}
|
||||
m_LocalPosition: {x: -6.424, y: 3.43913, z: -2.9829998}
|
||||
m_LocalPosition: {x: -6.405, y: 3.43913, z: -2.966}
|
||||
m_LocalScale: {x: 1, y: 0.014372, z: 0.7081001}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 127908880}
|
||||
- {fileID: 134307099}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 136.998, z: 0}
|
||||
--- !u!65 &902781403
|
||||
@@ -3112,6 +3145,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1072227175}
|
||||
- {fileID: 1203170782}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 317.496, z: 0}
|
||||
--- !u!65 &1055802464
|
||||
@@ -3225,6 +3259,7 @@ MonoBehaviour:
|
||||
DoorId: 1
|
||||
SceneToLoad: SampleScene
|
||||
IdOfCorrespondingDoor: 1
|
||||
WalkDirection: {fileID: 1203170782}
|
||||
--- !u!65 &1072227174
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3254,13 +3289,13 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1072227172}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
||||
m_LocalPosition: {x: -0.47499996, y: 34.3, z: 0.00000012626319}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.26100004, y: 34.299995, z: 0.000000057870626}
|
||||
m_LocalScale: {x: 1.1708915, y: 69.57974, z: 1.1708915}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1055802463}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1114011169
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3714,6 +3749,37 @@ Animator:
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
||||
--- !u!1 &1203170781
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1203170782}
|
||||
m_Layer: 0
|
||||
m_Name: RoomDirection
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1203170782
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1203170781}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.915, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1.1537358, y: 69.57974, z: 1.1885651}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1055802463}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1281708046
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -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;
|
||||
|
||||
if (playerController != null && GameSceneManager.Instance != null)
|
||||
{
|
||||
SceneDoor door = GameSceneManager.Instance.GetDoorWithId(doorId);
|
||||
|
||||
if (playerController != null && GameSceneManager.Instance != null)
|
||||
{
|
||||
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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -4,6 +4,10 @@ public class RoomDoor : Interactable
|
||||
{
|
||||
public RoomDoor linkedDoor;
|
||||
public bool requiresInteraction; // Do we need to press a button to enter?
|
||||
|
||||
// transform that the character should walk towards when entering the room
|
||||
// through this door
|
||||
public Transform WalkDirection;
|
||||
TeleportHandler teleportHandler;
|
||||
|
||||
// not required and only plays if interaction is required
|
||||
|
||||
@@ -11,6 +11,10 @@ public class SceneDoor : Interactable
|
||||
// Which door does this lead to in the scene this door takes us to?
|
||||
public int IdOfCorrespondingDoor = 0;
|
||||
|
||||
// transform that the character should walk towards when entering the room
|
||||
// through this door
|
||||
public Transform WalkDirection;
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
// Do nothing
|
||||
|
||||
@@ -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