From d78130ec4d89b2eab9d524ecd359c46fb2cf0860 Mon Sep 17 00:00:00 2001 From: JoshuaReason Date: Mon, 9 Sep 2019 13:21:47 +1000 Subject: [PATCH] Rotation is now cleaner --- .../Animations/CharacterController.controller | 413 +++++++++++++++++- .../{Scripts/Components.meta => Models.meta} | 2 +- .../Plugins/IngameDebugConsole/Android.meta | 8 + .../Plugins/IngameDebugConsole/Prefabs.meta | 8 + .../Plugins/IngameDebugConsole/Scripts.meta | 8 + .../IngameDebugConsole/Sprites/Unused.meta | 8 + Assets/Scenes/Menus/Lobby.unity | 2 +- Assets/Scripts/Character.cs | 136 ++++-- Assets/Scripts/Logic/Blocks/Rotate.cs | 4 +- Assets/Scripts/LogicBlocks.meta | 8 + 10 files changed, 536 insertions(+), 61 deletions(-) rename Assets/{Scripts/Components.meta => Models.meta} (77%) create mode 100644 Assets/Plugins/IngameDebugConsole/Android.meta create mode 100644 Assets/Plugins/IngameDebugConsole/Prefabs.meta create mode 100644 Assets/Plugins/IngameDebugConsole/Scripts.meta create mode 100644 Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta create mode 100644 Assets/Scripts/LogicBlocks.meta diff --git a/Assets/Animations/CharacterController.controller b/Assets/Animations/CharacterController.controller index 8a1de1c..b12dea9 100644 --- a/Assets/Animations/CharacterController.controller +++ b/Assets/Animations/CharacterController.controller @@ -21,6 +21,12 @@ AnimatorController: m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} + - m_Name: isSitting + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} - m_Name: Jump m_Type: 9 m_DefaultFloat: 0 @@ -33,6 +39,18 @@ AnimatorController: m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} + - m_Name: Hit + m_Type: 9 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} + - m_Name: SpeedMultiple + m_Type: 1 + m_DefaultFloat: 1 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Main @@ -46,6 +64,56 @@ AnimatorController: m_IKPass: 0 m_SyncedLayerAffectsTiming: 0 m_Controller: {fileID: 9100000} +--- !u!1101 &1101137190182981208 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: isSitting + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 1107044428114719794} + m_DstState: {fileID: 0} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.0126879215 + m_TransitionOffset: 0 + m_ExitTime: 0.8125 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &1101386882238539760 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: isRunning + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102812159766614166} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.0180372 + m_TransitionOffset: 0.6958886 + m_ExitTime: 0.986472 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &1101425544804232820 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -71,6 +139,31 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &1101494163837098496 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Hit + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102311993727884828} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.012069106 + m_TransitionOffset: 0 + m_ExitTime: 0.75 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &1101530445318437922 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -85,14 +178,158 @@ AnimatorStateTransition: m_Mute: 0 m_IsExit: 0 serializedVersion: 3 - m_TransitionDuration: 0.022549152 - m_TransitionOffset: 0.18196069 - m_ExitTime: 0.98696625 + m_TransitionDuration: 0.01025641 + m_TransitionOffset: 0.19118023 + m_ExitTime: 1.0086594 + m_HasExitTime: 1 + m_HasFixedDuration: 1 + m_InterruptionSource: 1 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &1101549412884486144 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: isWalking + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102276490540242372} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.03965509 + m_TransitionOffset: 0.31551716 + m_ExitTime: 0.97025853 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &1101576079442276262 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: [] + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 0} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 1 + serializedVersion: 3 + m_TransitionDuration: 0.111892164 + m_TransitionOffset: 0.037665866 + m_ExitTime: 0.8002211 + m_HasExitTime: 1 + m_HasFixedDuration: 1 + m_InterruptionSource: 2 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &1101728580691851412 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 2 + m_ConditionEvent: isWalking + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102373004189010166} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.03965521 + m_TransitionOffset: 0.15775858 + m_ExitTime: 0.94051707 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &1101785625070833912 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 2 + m_ConditionEvent: isSitting + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102240925324446728} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 1 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &1101823875389991086 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: [] + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102373004189010166} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.7580646 m_HasExitTime: 1 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &1101856588580977540 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 2 + m_ConditionEvent: isRunning + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102373004189010166} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.04460656 + m_TransitionOffset: 0 + m_ExitTime: 0.25000036 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &1101927995282899484 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -140,6 +377,60 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1102 &1102064491372911516 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Sit + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: + - {fileID: 1101785625070833912} + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 1 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400016, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} + m_Tag: + m_SpeedParameter: SpeedMultiple + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1102 &1102240925324446728 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Stand + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: + - {fileID: 1101576079442276262} + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 1 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400018, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} + m_Tag: + m_SpeedParameter: SpeedMultiple + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: --- !u!1102 &1102276490540242372 AnimatorState: serializedVersion: 5 @@ -150,19 +441,47 @@ AnimatorState: m_Name: Walk m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: 1101728580691851412} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 m_WriteDefaultValues: 1 m_Mirror: 0 - m_SpeedParameterActive: 0 + m_SpeedParameterActive: 1 m_MirrorParameterActive: 0 m_CycleOffsetParameterActive: 0 m_TimeParameterActive: 0 m_Motion: {fileID: 7400004, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: + m_SpeedParameter: SpeedMultiple + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1102 &1102311993727884828 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hit + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: + - {fileID: 1101823875389991086} + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 1 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400012, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} + m_Tag: + m_SpeedParameter: SpeedMultiple m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -183,13 +502,13 @@ AnimatorState: m_IKOnFeet: 0 m_WriteDefaultValues: 1 m_Mirror: 0 - m_SpeedParameterActive: 0 + m_SpeedParameterActive: 1 m_MirrorParameterActive: 0 m_CycleOffsetParameterActive: 0 m_TimeParameterActive: 0 m_Motion: {fileID: 7400008, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: + m_SpeedParameter: SpeedMultiple m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -203,7 +522,10 @@ AnimatorState: m_Name: Idle m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: 1101386882238539760} + - {fileID: 1101549412884486144} + - {fileID: 1101137190182981208} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -229,19 +551,20 @@ AnimatorState: m_Name: Run m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: 1101856588580977540} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 m_WriteDefaultValues: 1 m_Mirror: 0 - m_SpeedParameterActive: 0 + m_SpeedParameterActive: 1 m_MirrorParameterActive: 0 m_CycleOffsetParameterActive: 0 m_TimeParameterActive: 0 m_Motion: {fileID: 7400006, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: + m_SpeedParameter: SpeedMultiple m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -262,16 +585,41 @@ AnimatorState: m_IKOnFeet: 0 m_WriteDefaultValues: 1 m_Mirror: 0 - m_SpeedParameterActive: 0 + m_SpeedParameterActive: 1 m_MirrorParameterActive: 0 m_CycleOffsetParameterActive: 0 m_TimeParameterActive: 0 m_Motion: {fileID: 7400010, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: + m_SpeedParameter: SpeedMultiple m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1107 &1107044428114719794 +AnimatorStateMachine: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Sit + m_ChildStates: + - serializedVersion: 1 + m_State: {fileID: 1102064491372911516} + m_Position: {x: 264, y: 120, z: 0} + - serializedVersion: 1 + m_State: {fileID: 1102240925324446728} + m_Position: {x: 540, y: 120, z: 0} + m_ChildStateMachines: [] + m_AnyStateTransitions: [] + m_EntryTransitions: [] + m_StateMachineTransitions: {} + m_StateMachineBehaviours: [] + m_AnyStatePosition: {x: 50, y: 20, z: 0} + m_EntryPosition: {x: 50, y: 120, z: 0} + m_ExitPosition: {x: 800, y: 120, z: 0} + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} + m_DefaultState: {fileID: 1102064491372911516} --- !u!1107 &1107575609398583050 AnimatorStateMachine: serializedVersion: 5 @@ -286,25 +634,52 @@ AnimatorStateMachine: m_Position: {x: 576, y: 240, z: 0} - serializedVersion: 1 m_State: {fileID: 1102276490540242372} - m_Position: {x: 708, y: 420, z: 0} + m_Position: {x: 576, y: 420, z: 0} - serializedVersion: 1 m_State: {fileID: 1102812159766614166} - m_Position: {x: 444, y: 420, z: 0} + m_Position: {x: 348, y: 420, z: 0} - serializedVersion: 1 m_State: {fileID: 1102327515966221190} m_Position: {x: 468, y: 24, z: 0} - serializedVersion: 1 m_State: {fileID: 1102928467354121838} m_Position: {x: 696, y: 24, z: 0} - m_ChildStateMachines: [] + - serializedVersion: 1 + m_State: {fileID: 1102311993727884828} + m_Position: {x: 936, y: 24, z: 0} + m_ChildStateMachines: + - serializedVersion: 1 + m_StateMachine: {fileID: 1107044428114719794} + m_Position: {x: 816, y: 420, z: 0} m_AnyStateTransitions: - {fileID: 1101940742889338882} - {fileID: 1101425544804232820} + - {fileID: 1101494163837098496} m_EntryTransitions: [] - m_StateMachineTransitions: {} + m_StateMachineTransitions: + - first: {fileID: 1107044428114719794} + second: + - {fileID: 1109380621813599150} m_StateMachineBehaviours: [] m_AnyStatePosition: {x: 600, y: -132, z: 0} m_EntryPosition: {x: 252, y: 240, z: 0} - m_ExitPosition: {x: 1068, y: 252, z: 0} + m_ExitPosition: {x: 984, y: 576, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_DefaultState: {fileID: 1102373004189010166} +--- !u!1109 &1109380621813599150 +AnimatorTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 2 + m_ConditionEvent: isSitting + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1102373004189010166} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 1 diff --git a/Assets/Scripts/Components.meta b/Assets/Models.meta similarity index 77% rename from Assets/Scripts/Components.meta rename to Assets/Models.meta index 5a95b09..5346456 100644 --- a/Assets/Scripts/Components.meta +++ b/Assets/Models.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8d7394d70ec233849a60a26da5f23b75 +guid: 296bd90e667df1f4697823a0aa45acf0 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Plugins/IngameDebugConsole/Android.meta b/Assets/Plugins/IngameDebugConsole/Android.meta new file mode 100644 index 0000000..12049b6 --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Android.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3d7d7a61a5341904eb3c65af025b1d86 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Prefabs.meta b/Assets/Plugins/IngameDebugConsole/Prefabs.meta new file mode 100644 index 0000000..6aa8bf2 --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7dbc36665bc0d684db9a4447e27a7a4b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Scripts.meta b/Assets/Plugins/IngameDebugConsole/Scripts.meta new file mode 100644 index 0000000..72dcaac --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 860c08388401a6d4e858fe4910ea9337 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta new file mode 100644 index 0000000..f3769b1 --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f6caae32d463529478f2186f47c2e3fe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Menus/Lobby.unity b/Assets/Scenes/Menus/Lobby.unity index 2f9edb5..268db64 100644 --- a/Assets/Scenes/Menus/Lobby.unity +++ b/Assets/Scenes/Menus/Lobby.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ca249b9342dd6d663f6c8d0895426161e19f3cd8caaef902aa231cf4fa32aa33 +oid sha256:76d144d17d2449c33d10af1441e25d63a3345727027fcbddfa5482eb14db0163 size 46629 diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index 65beb0b..ec022d1 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -7,7 +7,7 @@ using Networking.Server; public class Character : MonoBehaviour { - public enum Animation { Walk, Run, Jump, Slide } + public enum Animation { Walk, Run, Jump, Sit, Attack, Hit } public string nextScene; Animator characterAnimator; @@ -101,57 +101,42 @@ public class Character : MonoBehaviour } } - public float yValue(float time, float heightMultiplier) - { - float y = Mathf.Sin((Mathf.PI * time)) * heightMultiplier; - return y; - } - public IEnumerator MoveToBlock(Block target, Animation animation, float time) { System.Func yFunction = null; + if (animation == Animation.Jump) + yFunction = (t) => Mathf.Sin((Mathf.PI * t)); - switch (animation) - { - case Animation.Walk: - characterAnimator.SetBool("isWalking", true); - break; - case Animation.Run: - characterAnimator.SetBool("isRunning", true); - break; - case Animation.Jump: - characterAnimator.SetTrigger("Jump"); - yFunction = (t) => yValue(t, 1.0f); - break; - default: - break; - } + StartAnimation(animation, time); - yield return StartCoroutine(LerpToBlock(target, time, yFunction)); + yield return StartCoroutine(LerpToBlock(target.VisualPosition, time, yFunction)); _currentBlock= target; - switch (animation) - { - case Animation.Walk: - characterAnimator.SetBool("isWalking", false); - break; - case Animation.Run: - characterAnimator.SetBool("isRunning", false); - break; - case Animation.Jump: - break; - default: - break; - } + StopAnimation(animation); } - public IEnumerator LerpToBlock(Block target, float time, System.Func heightOffset = null) + public IEnumerator RotateToDirection(Direction direction, Animation animation, float time, bool isLocal = true) + { + System.Func yFunction = null; + if (animation == Animation.Jump) + yFunction = (t) => Mathf.Sin((Mathf.PI * t)); + + Vector3 _endDir = isLocal ? direction.ToVector(transform) : direction.ToVector(); + + StartAnimation(animation, time); + + yield return StartCoroutine(LerpToRotation(_endDir, time, yFunction)); + + StopAnimation(animation); + } + + private IEnumerator LerpToBlock(Vector3 target, float time, System.Func heightOffset = null) { Vector3 _startPos = transform.position; - Vector3 _endPos = target.VisualPosition; + Vector3 _endPos = target; Vector3 _newPos; @@ -173,11 +158,84 @@ public class Character : MonoBehaviour _newPos = _endPos; if (heightOffset != null) - _newPos.y += heightOffset(elapsedTime / time); + _newPos.y += heightOffset(1); transform.position = _newPos; } + private IEnumerator LerpToRotation(Vector3 target, float time, System.Func heightOffset = null) + { + + Vector3 _startDir = transform.forward; + Vector3 _endDir = target; + + Vector3 _startPos = transform.position; + + float elapsedTime = 0; + while (elapsedTime / time < 1) + { + + transform.forward = Vector3.Slerp(_startDir, _endDir, (elapsedTime / time)); + + if (heightOffset != null) + transform.position = _startPos + Vector3.up * heightOffset(elapsedTime / time); + + yield return new WaitForEndOfFrame(); + + elapsedTime += Time.deltaTime; + } + + transform.forward = target; + + if (heightOffset != null) + transform.position = _startPos + Vector3.up * heightOffset(1); + } + + private void StartAnimation(Animation animation,float speed = 1) + { + characterAnimator.SetFloat("AnimationSpeed", (1 / speed)); + + switch (animation) + { + case Animation.Walk: + characterAnimator.SetBool("isWalking", true); + break; + case Animation.Run: + characterAnimator.SetBool("isRunning", true); + break; + case Animation.Sit: + characterAnimator.SetBool("isSitting", true); + break; + case Animation.Jump: + characterAnimator.SetTrigger("Jump"); + break; + case Animation.Attack: + characterAnimator.SetTrigger("Attack"); + break; + case Animation.Hit: + characterAnimator.SetTrigger("Hit"); + break; + default: + break; + } + } + + private void StopAnimation(Animation animation) + { + characterAnimator.SetFloat("AnimationSpeed", 1f); + switch (animation) + { + case Animation.Walk: + characterAnimator.SetBool("isWalking", false); + break; + case Animation.Run: + characterAnimator.SetBool("isRunning", false); + break; + case Animation.Sit: + characterAnimator.SetBool("isSitting", false); + break; + } + } IEnumerator JumpCoroutine(Block Target, Transform Current, float time, float heightMax) { diff --git a/Assets/Scripts/Logic/Blocks/Rotate.cs b/Assets/Scripts/Logic/Blocks/Rotate.cs index b586551..9bc5471 100644 --- a/Assets/Scripts/Logic/Blocks/Rotate.cs +++ b/Assets/Scripts/Logic/Blocks/Rotate.cs @@ -25,7 +25,9 @@ public class Rotate : LogicBlock /// Player to rotate protected override void BlockLogic(Character player, float animationTime) { - player.Rotate(direction, animationTime); + //player.Rotate(direction, animationTime); + + player.StartCoroutine(player.RotateToDirection(direction, Character.Animation.Jump, animationTime, true)); } /// diff --git a/Assets/Scripts/LogicBlocks.meta b/Assets/Scripts/LogicBlocks.meta new file mode 100644 index 0000000..98af9d1 --- /dev/null +++ b/Assets/Scripts/LogicBlocks.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8936b441d7647f74884c94f97bfb8931 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: