diff --git a/Assets/Data.meta b/Assets/Data.meta new file mode 100644 index 00000000..9f8d6a55 --- /dev/null +++ b/Assets/Data.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 729a098c9983605409ad6d82244ea633 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Data/Enemies.meta b/Assets/Data/Enemies.meta new file mode 100644 index 00000000..05e4f2a1 --- /dev/null +++ b/Assets/Data/Enemies.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72a0928af0d9f6341abd9532590e5e0d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Data/Enemies/NormalSkeleton.asset b/Assets/Data/Enemies/NormalSkeleton.asset new file mode 100644 index 00000000..848250bb --- /dev/null +++ b/Assets/Data/Enemies/NormalSkeleton.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fbf9bdf5c9924664eaf24e1e5b44fbce, type: 3} + m_Name: NormalSkeleton + m_EditorClassIdentifier: + health: 200 diff --git a/Assets/Data/Enemies/NormalSkeleton.asset.meta b/Assets/Data/Enemies/NormalSkeleton.asset.meta new file mode 100644 index 00000000..5a3f9daf --- /dev/null +++ b/Assets/Data/Enemies/NormalSkeleton.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d69b470386e043a4896f962a85c9346d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Data/Forge.meta b/Assets/Data/Forge.meta new file mode 100644 index 00000000..5f57fd35 --- /dev/null +++ b/Assets/Data/Forge.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6e822dce616f24b4bbe3b0987122b725 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Data/Forge/ForgeLevel.asset b/Assets/Data/Forge/ForgeLevel.asset new file mode 100644 index 00000000..cb28e7b0 --- /dev/null +++ b/Assets/Data/Forge/ForgeLevel.asset @@ -0,0 +1,21 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6113d1f06beb6a24cb28f2425b7ea301, type: 3} + m_Name: ForgeLevel + m_EditorClassIdentifier: + waves: + - timeToNextWave: 60 + timeToNextGroup: 5 + groups: + - prefab: {fileID: 9990444235481084, guid: 424e0fbef7cbe1e498d87b70b01f501e, type: 3} + count: 1 + timeToNext: 1 diff --git a/Assets/Data/Forge/ForgeLevel.asset.meta b/Assets/Data/Forge/ForgeLevel.asset.meta new file mode 100644 index 00000000..51d1a22b --- /dev/null +++ b/Assets/Data/Forge/ForgeLevel.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5c49530753c78b748aa4dfa919cca8e0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Models/Characters/Animations/skeleton controller.controller b/Assets/Models/Characters/Animations/skeleton controller.controller index d49006b3..d7ee62e2 100644 --- a/Assets/Models/Characters/Animations/skeleton controller.controller +++ b/Assets/Models/Characters/Animations/skeleton controller.controller @@ -1,5 +1,55 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1101 &-9106734440856624879 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 3 + m_ConditionEvent: Velocity + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 2810039473625123092} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.09747109 + m_TransitionOffset: 0 + m_ExitTime: 0.87093854 + m_HasExitTime: 0 + m_HasFixedDuration: 0 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &-8135275569169265678 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 4 + m_ConditionEvent: Velocity + m_EventTreshold: 0.1 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 3003194944102552249} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.77272725 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1107 &-6723335848530434233 AnimatorStateMachine: serializedVersion: 6 @@ -11,7 +61,10 @@ AnimatorStateMachine: m_ChildStates: - serializedVersion: 1 m_State: {fileID: 3003194944102552249} - m_Position: {x: 436, y: 310, z: 0} + m_Position: {x: 210, y: 250, z: 0} + - serializedVersion: 1 + m_State: {fileID: 2810039473625123092} + m_Position: {x: 210, y: 350, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] @@ -22,6 +75,21 @@ AnimatorStateMachine: m_ExitPosition: {x: 800, y: 120, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_DefaultState: {fileID: 3003194944102552249} +--- !u!206 &-5268009137298844095 +BlendTree: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: BlendTree + m_Childs: [] + m_BlendParameter: Velocity + m_BlendParameterY: Blend + m_MinThreshold: 0 + m_MaxThreshold: 1 + m_UseAutomaticThresholds: 1 + m_NormalizedBlendValues: 0 + m_BlendType: 0 --- !u!91 &9100000 AnimatorController: m_ObjectHideFlags: 0 @@ -30,7 +98,13 @@ AnimatorController: m_PrefabAsset: {fileID: 0} m_Name: skeleton controller serializedVersion: 5 - m_AnimatorParameters: [] + m_AnimatorParameters: + - m_Name: Velocity + m_Type: 1 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 9100000} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -44,6 +118,33 @@ AnimatorController: m_IKPass: 0 m_SyncedLayerAffectsTiming: 0 m_Controller: {fileID: 9100000} +--- !u!1102 &2810039473625123092 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Walk/Run + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: + - {fileID: -8135275569169265678} + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7605760797832953581} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: --- !u!1102 &3003194944102552249 AnimatorState: serializedVersion: 6 @@ -54,7 +155,8 @@ AnimatorState: m_Name: idle m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: -9106734440856624879} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -71,3 +173,36 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!206 &7605760797832953581 +BlendTree: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Blend Tree + m_Childs: + - serializedVersion: 2 + m_Motion: {fileID: -203655887218126122, guid: 6a302b3d9fdc2f5428377f6aa414f4b8, + type: 3} + m_Threshold: 0 + m_Position: {x: 0, y: 0} + m_TimeScale: 1 + m_CycleOffset: 0 + m_DirectBlendParameter: Velocity + m_Mirror: 0 + - serializedVersion: 2 + m_Motion: {fileID: -203655887218126122, guid: 2a0b4465077976b4c82716891c7b8c64, + type: 3} + m_Threshold: 1 + m_Position: {x: 0, y: 0} + m_TimeScale: 1 + m_CycleOffset: 0 + m_DirectBlendParameter: Velocity + m_Mirror: 0 + m_BlendParameter: Velocity + m_BlendParameterY: Velocity + m_MinThreshold: 0 + m_MaxThreshold: 1 + m_UseAutomaticThresholds: 1 + m_NormalizedBlendValues: 0 + m_BlendType: 0 diff --git a/Assets/Prefabs/Enemies/Enemy.prefab b/Assets/Prefabs/Enemies/Enemy.prefab index 6870fd7b..85097ca9 100644 --- a/Assets/Prefabs/Enemies/Enemy.prefab +++ b/Assets/Prefabs/Enemies/Enemy.prefab @@ -12,6 +12,8 @@ GameObject: - component: {fileID: 2957099991542780378} - component: {fileID: 5199431160857003883} - component: {fileID: 3716950706550494605} + - component: {fileID: 8845649797432163212} + - component: {fileID: 8368361186045338926} m_Layer: 0 m_Name: Enemy m_TagString: Untagged @@ -47,7 +49,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5272ea2f30f4ddb488b557c786c790fa, type: 3} m_Name: m_EditorClassIdentifier: - health: 100 + enemy: {fileID: 11400000, guid: d69b470386e043a4896f962a85c9346d, type: 2} + health: 200 isDead: 0 onDied: m_PersistentCalls: @@ -88,6 +91,73 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 647cabad96a59654cb4718c0bdf2ddd5, type: 3} m_Name: m_EditorClassIdentifier: + onTakeDamage: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 2957099991542780378} + m_TargetAssemblyTypeName: HealthComponent, Assembly-CSharp + m_MethodName: TakeDamage + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &8845649797432163212 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4528139036750849664} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b3f8cfc01629a2a4d8e8eeba3344c8f8, type: 3} + m_Name: + m_EditorClassIdentifier: + currentWaypointIndex: 0 + waypointGroup: {fileID: 0} + agent: {fileID: 0} + onVelocityChanged: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 3586119714840141587} + m_TargetAssemblyTypeName: AnimatorComponent, Assembly-CSharp + m_MethodName: UpdateVelocity + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!195 &8368361186045338926 +NavMeshAgent: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4528139036750849664} + m_Enabled: 1 + m_AgentTypeID: 0 + m_Radius: 0.5 + m_Speed: 3.5 + m_Acceleration: 8 + avoidancePriority: 50 + m_AngularSpeed: 120 + m_StoppingDistance: 0 + m_AutoTraverseOffMeshLink: 1 + m_AutoBraking: 1 + m_AutoRepath: 1 + m_Height: 2 + m_BaseOffset: 0 + m_WalkableMask: 4294967295 + m_ObstacleAvoidanceType: 4 --- !u!1001 &1695861871456640983 PrefabInstance: m_ObjectHideFlags: 0 @@ -182,6 +252,10 @@ PrefabInstance: m_RemovedGameObjects: [] m_AddedGameObjects: [] m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 1246891314395918, guid: cb4ff29f6f657bc4d94ed49c50a70be2, + type: 3} + insertIndex: -1 + addedObject: {fileID: 3586119714840141587} - targetCorrespondingSourceObject: {fileID: 1786365706177620, guid: cb4ff29f6f657bc4d94ed49c50a70be2, type: 3} insertIndex: -1 @@ -1513,6 +1587,25 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 +--- !u!1 &1696880047162615001 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 1246891314395918, guid: cb4ff29f6f657bc4d94ed49c50a70be2, + type: 3} + m_PrefabInstance: {fileID: 1695861871456640983} + m_PrefabAsset: {fileID: 0} +--- !u!114 &3586119714840141587 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1696880047162615001} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e22e730d77a8fa1488817a22b3acee38, type: 3} + m_Name: + m_EditorClassIdentifier: + animator: {fileID: 0} --- !u!1 &1696886475133429049 stripped GameObject: m_CorrespondingSourceObject: {fileID: 1235993377340142, guid: cb4ff29f6f657bc4d94ed49c50a70be2, diff --git a/Assets/Prefabs/Enemies/Skeleton.prefab b/Assets/Prefabs/Enemies/Skeleton.prefab new file mode 100644 index 00000000..9377a01f --- /dev/null +++ b/Assets/Prefabs/Enemies/Skeleton.prefab @@ -0,0 +1,70 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &4536338925929691516 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4528139036750849664, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_Name + value: Enemy + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6058054806151542978, guid: 34fa8d30155a6054680ec367434ae05f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 34fa8d30155a6054680ec367434ae05f, type: 3} diff --git a/Assets/Prefabs/Enemies/Skeleton.prefab.meta b/Assets/Prefabs/Enemies/Skeleton.prefab.meta new file mode 100644 index 00000000..81f660c9 --- /dev/null +++ b/Assets/Prefabs/Enemies/Skeleton.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 424e0fbef7cbe1e498d87b70b01f501e +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Forge.unity b/Assets/Scenes/Forge.unity index a1bae10c..16a0a0c4 100644 --- a/Assets/Scenes/Forge.unity +++ b/Assets/Scenes/Forge.unity @@ -55352,6 +55352,90 @@ Transform: type: 3} m_PrefabInstance: {fileID: 928661564} m_PrefabAsset: {fileID: 0} +--- !u!1 &929169822 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 929169823} + - component: {fileID: 929169824} + - component: {fileID: 929169825} + m_Layer: 0 + m_Name: Group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &929169823 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 929169822} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1831945567} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &929169824 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 929169822} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2c9625c5b7836584397b59b00907d6dc, type: 3} + m_Name: + m_EditorClassIdentifier: + XYZConstraint: 0 + waypoints: + - position: {x: 0, y: 0, z: 0} + rotation: {x: 0, y: 0, z: 0, w: 1} + xyzPosition: {x: 0, y: 0, z: 0} + xyPosition: {x: 0, y: 0, z: 0} + xzPosition: {x: 0, y: 0, z: 0} + - position: {x: 0, y: -0.31327057, z: -13.404602} + rotation: {x: 0, y: 0, z: 0, w: 1} + xyzPosition: {x: 0, y: -0.31327057, z: -13.404602} + xyPosition: {x: 0, y: -0.31327057, z: 0} + xzPosition: {x: 0, y: 0, z: -13.404602} + - position: {x: 0, y: -5.4797955, z: -24.073486} + rotation: {x: 0, y: 0, z: 0, w: 1} + xyzPosition: {x: 0, y: -5.4797955, z: -24.073486} + xyPosition: {x: 0, y: -5.4797955, z: 0} + xzPosition: {x: 0, y: 0, z: -24.073486} + - position: {x: 0, y: -5.4797955, z: -81.75009} + rotation: {x: 0, y: 0, z: 0, w: 1} + xyzPosition: {x: 0, y: -5.4797955, z: -81.75009} + xyPosition: {x: 0, y: -5.4797955, z: 0} + xzPosition: {x: 0, y: 0, z: -81.75009} + - position: {x: 0, y: -4.933069, z: -83.91342} + rotation: {x: 0, y: 0, z: 0, w: 1} + xyzPosition: {x: 0, y: -4.933069, z: -83.91342} + xyPosition: {x: 0, y: -4.933069, z: 0} + xzPosition: {x: 0, y: 0, z: -83.91342} +--- !u!114 &929169825 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 929169822} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 435f0c23cdef1c340bb304e83dc5d8a9, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &929311287 PrefabInstance: m_ObjectHideFlags: 0 @@ -61215,6 +61299,69 @@ Transform: type: 3} m_PrefabInstance: {fileID: 1030334691} m_PrefabAsset: {fileID: 0} +--- !u!1 &1030539045 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1030539047} + - component: {fileID: 1030539046} + m_Layer: 0 + m_Name: NavMesh Surface + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1030539046 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1030539045} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a5ac11cc976e418e8d13136b07e1f52, type: 3} + m_Name: + m_EditorClassIdentifier: + m_AgentTypeID: 0 + m_CollectObjects: 0 + m_Size: {x: 10, y: 10, z: 10} + m_Center: {x: 0, y: 2, z: 0} + m_LayerMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_UseGeometry: 1 + m_DefaultArea: 0 + m_GenerateLinks: 0 + m_IgnoreNavMeshAgent: 1 + m_IgnoreNavMeshObstacle: 1 + m_OverrideTileSize: 0 + m_TileSize: 256 + m_OverrideVoxelSize: 0 + m_VoxelSize: 0.16666667 + m_MinRegionArea: 2 + m_NavMeshData: {fileID: 23800000, guid: 585431ea3f8087a429faf4abd9c5a7cc, type: 2} + m_BuildHeightMesh: 0 +--- !u!4 &1030539047 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1030539045} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -11.93964, y: -12.243274, z: -291.8841} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1031041917 PrefabInstance: m_ObjectHideFlags: 0 @@ -109155,6 +109302,70 @@ Transform: type: 3} m_PrefabInstance: {fileID: 1831250045} m_PrefabAsset: {fileID: 0} +--- !u!1 &1831945566 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1831945567} + - component: {fileID: 1831945568} + m_Layer: 0 + m_Name: Waypoints + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1831945567 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1831945566} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -3.548, y: -14.462, z: -257.73} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 929169823} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1831945568 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1831945566} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d24ff1cd925ce404c913998a333b4fbd, type: 3} + m_Name: + m_EditorClassIdentifier: + level: {fileID: 11400000, guid: 5c49530753c78b748aa4dfa919cca8e0, type: 2} + currentWaveIndex: -1 + waveInProgress: 0 + spawnEnemy: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 929169825} + m_TargetAssemblyTypeName: SpawnComponent, Assembly-CSharp + m_MethodName: Spawn + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + waypointGroups: [] --- !u!1001 &1832625526 PrefabInstance: m_ObjectHideFlags: 0 @@ -128197,41 +128408,6 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 3716950706550494605, guid: 34fa8d30155a6054680ec367434ae05f, - type: 3} - propertyPath: onTakeDamage.m_PersistentCalls.m_Calls.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3716950706550494605, guid: 34fa8d30155a6054680ec367434ae05f, - type: 3} - propertyPath: onTakeDamage.m_PersistentCalls.m_Calls.Array.data[0].m_Mode - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3716950706550494605, guid: 34fa8d30155a6054680ec367434ae05f, - type: 3} - propertyPath: onTakeDamage.m_PersistentCalls.m_Calls.Array.data[0].m_Target - value: - objectReference: {fileID: 8713033016224012384} - - target: {fileID: 3716950706550494605, guid: 34fa8d30155a6054680ec367434ae05f, - type: 3} - propertyPath: onTakeDamage.m_PersistentCalls.m_Calls.Array.data[0].m_CallState - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 3716950706550494605, guid: 34fa8d30155a6054680ec367434ae05f, - type: 3} - propertyPath: onTakeDamage.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName - value: TakeDamage - objectReference: {fileID: 0} - - target: {fileID: 3716950706550494605, guid: 34fa8d30155a6054680ec367434ae05f, - type: 3} - propertyPath: onTakeDamage.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName - value: HealthComponent, Assembly-CSharp - objectReference: {fileID: 0} - - target: {fileID: 3716950706550494605, guid: 34fa8d30155a6054680ec367434ae05f, - type: 3} - propertyPath: onTakeDamage.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName - value: UnityEngine.Object, UnityEngine - objectReference: {fileID: 0} - target: {fileID: 4528139036750849664, guid: 34fa8d30155a6054680ec367434ae05f, type: 3} propertyPath: m_Name @@ -128292,18 +128468,6 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 34fa8d30155a6054680ec367434ae05f, type: 3} ---- !u!114 &8713033016224012384 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 2957099991542780378, guid: 34fa8d30155a6054680ec367434ae05f, - type: 3} - m_PrefabInstance: {fileID: 8713033016224012383} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5272ea2f30f4ddb488b557c786c790fa, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 @@ -128315,3 +128479,5 @@ SceneRoots: - {fileID: 120888407} - {fileID: 1711263980} - {fileID: 766107838} + - {fileID: 1831945567} + - {fileID: 1030539047} diff --git a/Assets/Scenes/Forge/NavMesh-NavMesh Surface.asset b/Assets/Scenes/Forge/NavMesh-NavMesh Surface.asset new file mode 100644 index 00000000..84243468 Binary files /dev/null and b/Assets/Scenes/Forge/NavMesh-NavMesh Surface.asset differ diff --git a/Assets/Scenes/Forge/NavMesh-NavMesh Surface.asset.meta b/Assets/Scenes/Forge/NavMesh-NavMesh Surface.asset.meta new file mode 100644 index 00000000..363bef24 --- /dev/null +++ b/Assets/Scenes/Forge/NavMesh-NavMesh Surface.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 585431ea3f8087a429faf4abd9c5a7cc +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 23800000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Components/AnimatorComponent.cs b/Assets/Scripts/Components/AnimatorComponent.cs new file mode 100644 index 00000000..b09ab6e8 --- /dev/null +++ b/Assets/Scripts/Components/AnimatorComponent.cs @@ -0,0 +1,27 @@ +using Sirenix.OdinInspector; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[RequireComponent(typeof(Animator))] +public class AnimatorComponent : MonoBehaviour +{ + [SerializeField] + [ReadOnly] + private Animator animator; + + [SerializeField] + [ReadOnly] + private float velocity; + + private void Awake() + { + animator = GetComponent(); + } + + public void UpdateVelocity(float velocity) + { + this.velocity = velocity; + animator.SetFloat("Velocity", velocity); + } +} diff --git a/Assets/Scripts/Components/AnimatorComponent.cs.meta b/Assets/Scripts/Components/AnimatorComponent.cs.meta new file mode 100644 index 00000000..f8670060 --- /dev/null +++ b/Assets/Scripts/Components/AnimatorComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e22e730d77a8fa1488817a22b3acee38 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Components/HealthComponent.cs b/Assets/Scripts/Components/HealthComponent.cs index 93d208f2..9ed538bf 100644 --- a/Assets/Scripts/Components/HealthComponent.cs +++ b/Assets/Scripts/Components/HealthComponent.cs @@ -7,6 +7,11 @@ using UnityEngine.EventSystems; public class HealthComponent : MonoBehaviour { + [SerializeField] + [Required] + [OnValueChanged("Setup")] + private Enemy enemy; + [ReadOnly] [SerializeField] private int health; @@ -20,7 +25,7 @@ public class HealthComponent : MonoBehaviour [Button] public void Setup() { - health = 100; + health = enemy.health; isDead = false; } diff --git a/Assets/Scripts/Components/NavMeshComponent.cs b/Assets/Scripts/Components/NavMeshComponent.cs new file mode 100644 index 00000000..afdb64ae --- /dev/null +++ b/Assets/Scripts/Components/NavMeshComponent.cs @@ -0,0 +1,76 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Sirenix.OdinInspector; +using UnityEngine.AI; +using UnityEngine.Events; + +[RequireComponent(typeof(NavMeshAgent))] +public class NavMeshComponent : MonoBehaviour +{ + [SerializeField] + [ReadOnly] + public int currentWaypointIndex = 0; + + [SerializeField] + [ReadOnly] + public WaypointsGroup waypointGroup; + + [SerializeField] + [ReadOnly] + private NavMeshAgent agent; + + [SerializeField] + private UnityEvent onVelocityChanged; + + private void Awake() + { + agent = GetComponent(); + } + + public void MoveTo(WaypointsGroup waypointGroup) + { + this.waypointGroup = waypointGroup; + + MoveToNext(); + } + + private void MoveToNext() + { + currentWaypointIndex++; + agent.destination = waypointGroup.waypoints[currentWaypointIndex] + .GetPosition(); + } + + private void Update() + { + var velocity = agent.velocity.magnitude / agent.speed; + onVelocityChanged.Invoke(velocity); + + if (waypointGroup == null) + return; + + if (ReachedDestinationOrGaveUp()) + { + if (currentWaypointIndex != waypointGroup.waypoints.Count - 1) + { + MoveToNext(); + } + } + } + + private bool ReachedDestinationOrGaveUp() + { + + if (agent.pathPending) + return false; + + if (agent.remainingDistance > agent.stoppingDistance) + return false; + + if (!(!agent.hasPath || agent.velocity.sqrMagnitude == 0f)) + return false; + + return true; + } +} diff --git a/Assets/Scripts/Components/NavMeshComponent.cs.meta b/Assets/Scripts/Components/NavMeshComponent.cs.meta new file mode 100644 index 00000000..80ced4e5 --- /dev/null +++ b/Assets/Scripts/Components/NavMeshComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b3f8cfc01629a2a4d8e8eeba3344c8f8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Components/SpawnComponent.cs b/Assets/Scripts/Components/SpawnComponent.cs new file mode 100644 index 00000000..940bbcc9 --- /dev/null +++ b/Assets/Scripts/Components/SpawnComponent.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpawnComponent : MonoBehaviour +{ + public void Spawn(SpawnInformation info) + { + var gameObject = Instantiate(info.prefab, transform); + gameObject.transform.position = info.position; + gameObject.name = info.prefab.name; + info.onSpawned.Invoke(gameObject); + } +} diff --git a/Assets/Scripts/Components/SpawnComponent.cs.meta b/Assets/Scripts/Components/SpawnComponent.cs.meta new file mode 100644 index 00000000..c8efde9b --- /dev/null +++ b/Assets/Scripts/Components/SpawnComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 435f0c23cdef1c340bb304e83dc5d8a9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Data/Enemy.cs b/Assets/Scripts/Data/Enemy.cs new file mode 100644 index 00000000..30e2c789 --- /dev/null +++ b/Assets/Scripts/Data/Enemy.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +[CreateAssetMenu(fileName = "Enemy", menuName = "Data/Enemy")] +public class Enemy : ScriptableObject +{ + [SerializeField] + public int health; +} \ No newline at end of file diff --git a/Assets/Scripts/Data/Enemy.cs.meta b/Assets/Scripts/Data/Enemy.cs.meta new file mode 100644 index 00000000..6b4ad85a --- /dev/null +++ b/Assets/Scripts/Data/Enemy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fbf9bdf5c9924664eaf24e1e5b44fbce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Data/Level.cs b/Assets/Scripts/Data/Level.cs new file mode 100644 index 00000000..33b5e8d9 --- /dev/null +++ b/Assets/Scripts/Data/Level.cs @@ -0,0 +1,11 @@ +using Sirenix.OdinInspector; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu(fileName = "Level", menuName = "Data/Level")] +public class Level : ScriptableObject +{ + [SerializeField] + public Wave[] waves = new Wave[0]; +} diff --git a/Assets/Scripts/Data/Level.cs.meta b/Assets/Scripts/Data/Level.cs.meta new file mode 100644 index 00000000..c28a4ac5 --- /dev/null +++ b/Assets/Scripts/Data/Level.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6113d1f06beb6a24cb28f2425b7ea301 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Data/SpawnInformation.cs b/Assets/Scripts/Data/SpawnInformation.cs new file mode 100644 index 00000000..2da0edac --- /dev/null +++ b/Assets/Scripts/Data/SpawnInformation.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +public class SpawnInformation +{ + [SerializeField] + public GameObject prefab; + + [SerializeField] + public Vector3 position; + + [SerializeField] + public Action onSpawned; + + public SpawnInformation( + GameObject prefab, + Vector3 position, + Action onSpawned) + { + this.prefab = prefab; + this.position = position; + this.onSpawned = onSpawned; + } +} diff --git a/Assets/Scripts/Data/SpawnInformation.cs.meta b/Assets/Scripts/Data/SpawnInformation.cs.meta new file mode 100644 index 00000000..32e5434e --- /dev/null +++ b/Assets/Scripts/Data/SpawnInformation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 30cb692399aec2148bec8ce075f3cac8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Data/Wave.cs b/Assets/Scripts/Data/Wave.cs new file mode 100644 index 00000000..3c64bbde --- /dev/null +++ b/Assets/Scripts/Data/Wave.cs @@ -0,0 +1,26 @@ +using Sirenix.OdinInspector; +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +public class Wave +{ + [HorizontalGroup("Split", width: 130)] + [VerticalGroup("Split/Left")] + [Title("Time To Next Wave")] + [HideLabel] + [SerializeField] + public float timeToNextWave = 60; + + [Title("Time To Next Group")] + [HideLabel] + [VerticalGroup("Split/Left")] + [SerializeField] + public float timeToNextGroup = 1; + + [VerticalGroup("Split/Right")] + [SerializeField] + public WaveGroup[] groups = new WaveGroup[0]; +} diff --git a/Assets/Scripts/Data/Wave.cs.meta b/Assets/Scripts/Data/Wave.cs.meta new file mode 100644 index 00000000..295f3c28 --- /dev/null +++ b/Assets/Scripts/Data/Wave.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 00d898c9ee1f3f543853c351aa4de552 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Data/WaveGroup.cs b/Assets/Scripts/Data/WaveGroup.cs new file mode 100644 index 00000000..6d625a6b --- /dev/null +++ b/Assets/Scripts/Data/WaveGroup.cs @@ -0,0 +1,35 @@ +using Sirenix.OdinInspector; +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +public class WaveGroup +{ + [SerializeField] + [AssetsOnly] + [Required] + public GameObject prefab; + + [SerializeField] + [Range(1, 30)] + public int count = 1; + + [SerializeField] + [Range(0, 30)] + [LabelText("Time to next")] + public float timeToNext = 1; + + //[LabelText("1")] + //[HorizontalGroup(Title = "Waypoint group")] + //public bool inWaypointGroup1; + + //[LabelText("2")] + //[HorizontalGroup] + //public bool inWaypointGroup2; + + //[LabelText("3")] + //[HorizontalGroup] + //public bool inWaypointGroup3; +} \ No newline at end of file diff --git a/Assets/Scripts/Data/WaveGroup.cs.meta b/Assets/Scripts/Data/WaveGroup.cs.meta new file mode 100644 index 00000000..362f426f --- /dev/null +++ b/Assets/Scripts/Data/WaveGroup.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e9b63d2d9d8d3ae43b8bb7d8c8fc8e82 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Managers.meta b/Assets/Scripts/Managers.meta new file mode 100644 index 00000000..61d809b5 --- /dev/null +++ b/Assets/Scripts/Managers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 524fe00bb628d7a42abaca8d223206d8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Managers/WaveManager.cs b/Assets/Scripts/Managers/WaveManager.cs new file mode 100644 index 00000000..5a1f0576 --- /dev/null +++ b/Assets/Scripts/Managers/WaveManager.cs @@ -0,0 +1,83 @@ +using Sirenix.OdinInspector; +using Sirenix.Utilities; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.Events; + +public class WaveManager : MonoBehaviour +{ + [SerializeField] + private Level level; + + [SerializeField] + [ReadOnly] + private int currentWaveIndex = -1; + + private Wave currentWave { + get { return level.waves[currentWaveIndex]; } + } + + [SerializeField] + [ReadOnly] + private bool waveInProgress = false; + + private bool isLastWave { + get { return currentWaveIndex == level.waves.Length - 1; } + } + + public UnityEvent spawnEnemy; + + [SerializeField] + [ReadOnly] + private WaypointsGroup[] waypointGroups; + + [DisableInEditorMode] + [Button] + private void StartNextWave() + { + if (waypointGroups.IsNullOrEmpty()) + { + Debug.LogWarning("No waypoint groups set in wave manager"); + return; + } + + if (waveInProgress) return; + + if (isLastWave) return; + + currentWaveIndex++; + waveInProgress = true; + + StartCoroutine(SpawnWave()); + } + + private void Start() + { + waypointGroups = GetComponentsInChildren(); + StartNextWave(); + } + + private IEnumerator SpawnWave() + { + foreach (var spawn in currentWave.groups) + { + for (var i = 0; i < spawn.count; i++) + { + spawnEnemy.Invoke(new(spawn.prefab, transform.position, (enemy) => + { + var agent = enemy.GetComponent(); + agent.MoveTo(waypointGroups.First()); + })); + + yield return new WaitForSeconds(spawn.timeToNext); + } + + yield return new WaitForSeconds(currentWave.timeToNextGroup); + } + + + } +} diff --git a/Assets/Scripts/Managers/WaveManager.cs.meta b/Assets/Scripts/Managers/WaveManager.cs.meta new file mode 100644 index 00000000..9f5232a7 --- /dev/null +++ b/Assets/Scripts/Managers/WaveManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d24ff1cd925ce404c913998a333b4fbd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Waypoints.meta b/Assets/Scripts/Waypoints.meta new file mode 100644 index 00000000..f7823eb9 --- /dev/null +++ b/Assets/Scripts/Waypoints.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: acd1bffb56e5bc9438bbefba06adbf6f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Waypoints/Editor.meta b/Assets/Scripts/Waypoints/Editor.meta new file mode 100644 index 00000000..e763375e --- /dev/null +++ b/Assets/Scripts/Waypoints/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8b951cba42bf31948bff38a5dc64fe4c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Waypoints/Editor/WaypointsGroupEditor.cs b/Assets/Scripts/Waypoints/Editor/WaypointsGroupEditor.cs new file mode 100644 index 00000000..f9b4dbad --- /dev/null +++ b/Assets/Scripts/Waypoints/Editor/WaypointsGroupEditor.cs @@ -0,0 +1,232 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +[CustomEditor(typeof(WaypointsGroup))] +public class WaypointsGroupEditor : Editor +{ + WaypointsGroup waypointsGroup; + List waypoints; + + Waypoint selectedWaypoint = null; + + private void OnEnable() + { + waypointsGroup = target as WaypointsGroup; + waypoints = waypointsGroup.GetWaypointChildren(); + } + + private void OnSceneGUI() + { + DrawWaypoints(waypoints ); + } + + override public void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.BeginVertical(); + + EditorGUILayout.LabelField("Waypoints"); + + bool dorepaint = false; + + + if (waypoints != null) + { + + + + int delIndex = -1; + for (int cnt = 0; cnt < waypoints.Count; cnt++) + { + Color guiColor = GUI.color; + + Waypoint cwp = waypoints[cnt]; + + if (cwp == selectedWaypoint) + GUI.color = Color.green; + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("S", GUILayout.Width(20))) + { + if(selectedWaypoint == cwp) + { + selectedWaypoint = null; + } + else + { + selectedWaypoint = cwp; + } + + dorepaint = true; + + } + + EditorGUI.BeginChangeCheck(); + Vector3 oldV = cwp.GetPosition(waypointsGroup.XYZConstraint); + Vector3 newV = EditorGUILayout.Vector3Field("", oldV); + if(EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(waypointsGroup, "Waypoint Moved"); + cwp.UpdatePosition(newV - oldV, waypointsGroup.XYZConstraint); + } + + + + if (GUILayout.Button("D", GUILayout.Width(25))) + { + delIndex = cnt; + dorepaint = true; + + } + GUI.color = guiColor; + EditorGUILayout.EndHorizontal(); + + } + + if (delIndex > -1) + { + if (waypoints[delIndex] == selectedWaypoint) + selectedWaypoint = null; + waypoints.RemoveAt(delIndex); + } + + } + + + if (GUILayout.Button("Add")) + { + Undo.RecordObject(waypointsGroup, "Waypoint Added"); + int ndx = -1; + if(selectedWaypoint != null) + { + ndx = waypoints.IndexOf(selectedWaypoint); + if (ndx == -1) + selectedWaypoint = null; + else + ndx += 1; + } + + + Waypoint wp = new Waypoint(); + wp.CopyOther(selectedWaypoint); + waypointsGroup.AddWaypoint(wp, ndx); + selectedWaypoint = wp; + dorepaint = true; + + } + + EditorGUILayout.EndVertical(); + if (dorepaint) + { + SceneView.RepaintAll(); + } + + } + + public void DrawWaypoints(List waypoints) + { + bool doRepaint = false; + if (waypoints != null) + { + + int cnt = 0; + foreach (Waypoint wp in waypoints) + { + doRepaint |= DrawInScene(wp); + + // Draw a pointer line + if(cnt < waypoints.Count-1) + { + Waypoint wpnext = waypoints[cnt+1]; + Handles.DrawLine(wp.GetPosition(waypointsGroup.XYZConstraint), wpnext.GetPosition(waypointsGroup.XYZConstraint)); + } + else + { + Waypoint wpnext = waypoints[0]; + Color c = Handles.color; + Handles.color = Color.gray; + Handles.DrawLine(wp.GetPosition(waypointsGroup.XYZConstraint), wpnext.GetPosition(waypointsGroup.XYZConstraint)); + Handles.color = c; + } + cnt += 1; + } + } + if(doRepaint) + { + Repaint(); + } + + } + + + public bool DrawInScene(Waypoint waypoint, int controlID = -1) + { + if (waypoint == null) + { + Debug.Log("NO WP!"); + return false; + } + + bool doRepaint = false; + //None serialized field, gets "lost" during serailize updates; + waypoint.SetWaypointGroup(waypointsGroup); + + + + if (selectedWaypoint == waypoint) + { + Color c = Handles.color; + Handles.color = Color.green; + + //Vector3 newPos = Handles.FreeMoveHandle(waypoint.GetPosition(), waypoint.rotation, 1.0f, Vector3.zero, Handles.SphereHandleCap); + EditorGUI.BeginChangeCheck(); + Vector3 oldpos = waypoint.GetPosition(waypointsGroup.XYZConstraint); + Vector3 newPos = Handles.PositionHandle(oldpos, waypoint.rotation); + + float handleSize = HandleUtility.GetHandleSize(newPos); + + Handles.SphereHandleCap(-1, newPos, waypoint.rotation, 0.25f * handleSize, EventType.Repaint); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(waypointsGroup, "Waypoint Moved"); + waypoint.UpdatePosition(newPos - oldpos, waypointsGroup.XYZConstraint); + } + + Handles.color = c; + + } + else + { + Vector3 currPos = waypoint.GetPosition(waypointsGroup.XYZConstraint); + float handleSize = HandleUtility.GetHandleSize(currPos); + if (Handles.Button(currPos, waypoint.rotation, 0.25f * handleSize, 0.25f * handleSize, Handles.SphereHandleCap)) + { + doRepaint = true; + selectedWaypoint = waypoint; + } + + } + return doRepaint; + } + + + + + + + // Menu item for creating a waypoints group + [MenuItem("GameObject/WaypointsFree/Create WaypointsGroup")] + public static void CreateRFPathManager() + { + GameObject go = new GameObject("WaypointsGroup"); + go.AddComponent(); + // Select it: + Selection.activeGameObject = go; + + + } + + +} \ No newline at end of file diff --git a/Assets/Scripts/Waypoints/Editor/WaypointsGroupEditor.cs.meta b/Assets/Scripts/Waypoints/Editor/WaypointsGroupEditor.cs.meta new file mode 100644 index 00000000..55f99789 --- /dev/null +++ b/Assets/Scripts/Waypoints/Editor/WaypointsGroupEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 08bf8998ce77c2245ba5d8436ec723b2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Waypoints/Waypoint.cs b/Assets/Scripts/Waypoints/Waypoint.cs new file mode 100644 index 00000000..0f427c60 --- /dev/null +++ b/Assets/Scripts/Waypoints/Waypoint.cs @@ -0,0 +1,141 @@ +using System; +using UnityEngine; + +public enum PositionConstraint +{ + XYZ, // 3D + XY, // 2D + XZ // 2D +} + +/// +/// Traversal direction for list of waypoints (in the WaypointpointsGroup) +/// +public enum TravelDirection +{ + FORWARD, // 0 to Length-1 + REVERSE // Length-1 to 0 +} +public enum EndpointBehavior +{ + STOP, // Movement stops when end position reached + LOOP, // Movement loops back to first position + PINGPONG, // Reverse direction through the the positions list +} +public enum MoveType +{ + LERP, // Uses the MoveLerpSimple function to update transform position + FORWARD_TRANSLATE // uses MoveForwardToNext function to translate position - ROTATION DEPENDENT! +} + + +/// +/// Waypoint class - managed through the WaypointGroups editor +/// +/// +[Serializable] +public class Waypoint +{ + // OFFSET position to parent WaypointsGroup; + // Use GETPOSITION to read properly (as it depends on the PositionConstraint of the WaypointGroup parent) + public Vector3 position; + + [HideInInspector] + public Quaternion rotation = Quaternion.identity; + + [SerializeField] + [HideInInspector] + Vector3 xyzPosition; // OFFSET position to parent WaypointsGroup + + [HideInInspector] + [SerializeField] + Vector3 xyPosition; // OFFSET position to parent WaypointsGroup + + [HideInInspector] + [SerializeField] + Vector3 xzPosition; // OFFSET position to parent WaypointsGroup + + WaypointsGroup wpGroup; + + + public Vector3 XY + { + get { return xyPosition; } + } + + public Vector3 XYZ + { + get { return xyzPosition; } + } + public Vector3 XZ + { + get { return xzPosition; } + } + + + public void SetWaypointGroup(WaypointsGroup wpg) + { + wpGroup = wpg; + } + + public void CopyOther(Waypoint other) + { + if (other == null) return; + + xyPosition = other.XY; + xzPosition = other.XZ; + xyzPosition = other.XYZ; + + Debug.Log(other.XYZ); + Debug.Log(xyzPosition); + } + + public Vector3 GetPosition(PositionConstraint constraint=PositionConstraint.XYZ) + { + if(wpGroup != null) + { + constraint = wpGroup.XYZConstraint; + } + + if (constraint == PositionConstraint.XY) + position = xyPosition; + else if (constraint == PositionConstraint.XZ) + position = xzPosition; + else + position = xyzPosition; + + if (wpGroup != null) + return wpGroup.transform.position + position; + else + return position; + } + + public void UpdatePosition( Vector3 newPos, PositionConstraint constraint ) + { + + xyPosition.x += newPos.x; + xzPosition.x += newPos.x; + xyzPosition.x += newPos.x; + + if(constraint == PositionConstraint.XY) + { + xyzPosition.y += newPos.y; + xyPosition.y += newPos.y; + } + else if(constraint == PositionConstraint.XZ) + { + xzPosition.z += newPos.z; + xyzPosition.z += newPos.z; + } + else if(constraint == PositionConstraint.XYZ) + { + xyzPosition.y += newPos.y; + xyzPosition.z += newPos.z; + + xyPosition.y += newPos.y; + xzPosition.z += newPos.z; + } + + } + +} \ No newline at end of file diff --git a/Assets/Scripts/Waypoints/Waypoint.cs.meta b/Assets/Scripts/Waypoints/Waypoint.cs.meta new file mode 100644 index 00000000..05522f72 --- /dev/null +++ b/Assets/Scripts/Waypoints/Waypoint.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 524ba8ae70727da4283498854cea1ca8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Waypoints/WaypointsGroup.cs b/Assets/Scripts/Waypoints/WaypointsGroup.cs new file mode 100644 index 00000000..54b643a2 --- /dev/null +++ b/Assets/Scripts/Waypoints/WaypointsGroup.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class WaypointsGroup : MonoBehaviour +{ + public PositionConstraint XYZConstraint = PositionConstraint.XYZ; + [HideInInspector] + public List waypoints; // The waypoint components controlled by this WaypointsGroupl IMMEDIATE children only + + private void Awake() + { + if(waypoints != null) + { + foreach (Waypoint wp in waypoints) + wp.SetWaypointGroup(this); + } + } + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } + + /// + /// Returns a list of Waypoints; resets the parent transform if reparent == true + /// + /// + public List GetWaypointChildren(bool reparent = true) + { + if (waypoints == null) + waypoints = new List(); + + if(reparent == true) + { + foreach (Waypoint wp in waypoints) + wp.SetWaypointGroup(this); + } + + + return waypoints; + } + + + public void AddWaypoint(Waypoint wp, int ndx = -1) + { + if (waypoints == null) waypoints = new List(); + if (ndx == -1) + waypoints.Add(wp); + else + waypoints.Insert(ndx, wp); + wp.SetWaypointGroup(this); + } + +} \ No newline at end of file diff --git a/Assets/Scripts/Waypoints/WaypointsGroup.cs.meta b/Assets/Scripts/Waypoints/WaypointsGroup.cs.meta new file mode 100644 index 00000000..c8764fe5 --- /dev/null +++ b/Assets/Scripts/Waypoints/WaypointsGroup.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2c9625c5b7836584397b59b00907d6dc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Waypoints/WaypointsTraveler.cs b/Assets/Scripts/Waypoints/WaypointsTraveler.cs new file mode 100644 index 00000000..a026adbe --- /dev/null +++ b/Assets/Scripts/Waypoints/WaypointsTraveler.cs @@ -0,0 +1,369 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class WaypointsTraveler : MonoBehaviour +{ + [Tooltip("WaypointsGroup gameobject containing the waypoints to travel.")] + public WaypointsGroup Waypoints = null; + + [Tooltip("Movement and look-at constraints.")] + public PositionConstraint XYZConstraint = PositionConstraint.XYZ; + + + [Tooltip("Auto-start movement if true.")] + public bool AutoStart = false; + + //[Range(0,float.MaxValue)] + public float MoveSpeed = 5.0f; + + //[Range(0, float.MaxValue)] + public float LookAtSpeed = 3.0f; + + [Tooltip("Starts movement from the position vector at this index. Dependent upon StartTravelDirection!")] + public int StartIndex = 0; + + + [Tooltip("Immediately move starting position to postion at StartIndex.")] + public bool AutoPositionAtStart = true; + + [Tooltip("Initial direction of travel through the positions list.")] + public TravelDirection StartTravelDirection = TravelDirection.FORWARD; + + [Tooltip("Movement behavior to apply when last postion reached.")] + public EndpointBehavior EndReachedBehavior = EndpointBehavior.LOOP; + + [Tooltip("Movement function type")] + public MoveType StartingMovementType = MoveType.LERP; + + + public bool IsMoving + { + get { return isMoving; } + } + + delegate bool MovementFunction (); + MovementFunction moveFunc = null; + + + + int positionIndex = -1; // Index of the next waypoint to move toward + List waypointsList; //Reference to the list of waypoints located in Waypoints + + + Vector3 nextPosition; // The next position to travel to. + Vector3 startPosition; + Vector3 destinationPosition; + + float distanceToNextWaypoint; + float distanceTraveled = 0; + float timeTraveled = 0; + + int travelIndexCounter = 1; + + bool isMoving = false; // Movement on/off + + + + Vector3 positionOriginal; + Quaternion rotationOriginal; + float moveSpeedOriginal = 0; + float lookAtSpeedOriginal = 0; + + + + public void ResetTraveler() + { + transform.position = positionOriginal; + transform.rotation = rotationOriginal; + + MoveSpeed = moveSpeedOriginal; + LookAtSpeed = lookAtSpeedOriginal; + + + StartAtIndex(StartIndex, AutoPositionAtStart); + SetNextPosition(); + travelIndexCounter = StartTravelDirection == TravelDirection.REVERSE ? -1 : 1; + + if (StartingMovementType == MoveType.LERP) + moveFunc = MoveLerpSimple; + else if (StartingMovementType == MoveType.FORWARD_TRANSLATE) + moveFunc = MoveForwardToNext; + + } + + // Start is called before the first frame update + void Start() + { + moveSpeedOriginal = MoveSpeed; + lookAtSpeedOriginal = LookAtSpeed; + + positionOriginal = transform.position; + rotationOriginal = transform.rotation; + + ResetTraveler(); + + Move( AutoStart ); + + } + + public void Move(bool tf) + { + isMoving = tf; + } + + private void Awake() + { + if (Waypoints != null) + { + waypointsList = Waypoints.waypoints; + } + } + + // Update is called once per frame + void Update() + { + if (isMoving == true && moveFunc != null) + { + bool arrivedAtDestination = false; + + // Call the delegate Movement Function... + arrivedAtDestination = moveFunc(); + + if (arrivedAtDestination == true) + { + SetNextPosition(); + } + } + } + + /// + /// Setup the list of positions to follow + /// + /// List of Vector3s indicating move-to locations + public void SetWaypointsGroup(WaypointsGroup newGroup) + { + Waypoints = newGroup; + waypointsList = null; + if(newGroup != null) + { + waypointsList = newGroup.waypoints; + } + + } + + + /// + /// Sets the position to beging moving toward; if autpAupdatePostion is true, then start + /// at that index-related position immediately. + /// + /// + /// + void StartAtIndex(int ndx, bool autoUpdatePosition = true) + { + if (StartTravelDirection == TravelDirection.REVERSE) + ndx = waypointsList.Count - ndx - 1; + + ndx = Mathf.Clamp(ndx, 0, waypointsList.Count - 1); + positionIndex = ndx - 1; + if (autoUpdatePosition) + { + transform.position = waypointsList[ndx].GetPosition(); + if(LookAtSpeed > 0) + { + if (StartTravelDirection == TravelDirection.REVERSE) + { + ndx -= 1; + if (ndx < 0) ndx = waypointsList.Count - 1; + } + else + { + ndx += 1; + if (ndx >= waypointsList.Count) + ndx = 0; + } + + /* + Waypoint wp = waypointsList[ndx]; + Vector3 wpPos = wp.GetPosition(); + Vector3 worldUp = Vector3.forward; + + transform.LookAt(wpPos, worldUp); + */ + } + } + } + + + + /// + /// Fetch the next waypoint position in the waypoints list + /// Depending on Endpoint behavior, ping pong, loop, or stop. + /// - Stop : Stops movement at the endpoint + /// - Ping Pong: reverses traveseral of the Waypoint Positions list + /// - Loop : Resets the index to 0; restarting at the first waypoint + /// + void SetNextPosition() + { + int posCount = waypointsList.Count; + if (posCount > 0) + { + + // Reached the endpoint; determing what do do next + if( (positionIndex == 0 && travelIndexCounter < 0) || (positionIndex == posCount - 1 && travelIndexCounter > 0)) + { + // Stop moving when an endpoint is reached + if(EndReachedBehavior == EndpointBehavior.STOP) + { + isMoving = false; + return; + } + + // Continue movement, but reverse direction + else if(EndReachedBehavior == EndpointBehavior.PINGPONG) + { + travelIndexCounter = -travelIndexCounter; + } + + // General Loop (default) + else if (EndReachedBehavior == EndpointBehavior.LOOP) + { + + } + + } + + + positionIndex += travelIndexCounter; + + if (positionIndex >= posCount) + positionIndex = 0; + else if (positionIndex < 0) + positionIndex = posCount - 1; + + + nextPosition = waypointsList[positionIndex].GetPosition(); + if (XYZConstraint == PositionConstraint.XY) + { + nextPosition.z = transform.position.z; + } + else if (XYZConstraint == PositionConstraint.XZ) + { + nextPosition.y = transform.position.y; + } + + ResetMovementValues(); + } + } + + /// + /// Reset movement metrics based on the current transform postion and the next waypoint. + /// + void ResetMovementValues() + { + // Update current position, distance, and start time -- used in Update to move the transform + startPosition = transform.position; + destinationPosition = nextPosition; + distanceToNextWaypoint = Vector3.Distance(startPosition, destinationPosition); + distanceTraveled = 0; + timeTraveled = 0; + + } + + /// + /// Uses a Vector3 Lerp function to update the gameobject's transform position. + /// MoveSpeed needs to be > 0 + /// + /// + bool MoveLerpSimple() + { + if (MoveSpeed < 0) + MoveSpeed = 0; + + timeTraveled += Time.deltaTime; + distanceTraveled += Time.deltaTime * MoveSpeed; + float fracAmount = distanceTraveled / distanceToNextWaypoint; + transform.position = Vector3.Lerp(startPosition, destinationPosition, fracAmount); + // set LookAt speed to 0 if no rotation toward the destination is desired. + UpdateLookAtRotation(); + return fracAmount >= 1; + } + + /// + /// Translates the waypoint traveler using the forward direction. Note that "forward" is dependent + /// upon the directional/position constraint. + /// - XYZ: Vector3.forward + /// - XY : Vector3.up + /// - XZ : Vector3.right + /// + /// -- When using this method of translation, LOOKATSPEED must be > 0. + /// + /// + bool MoveForwardToNext() + { + if (MoveSpeed < 0) + MoveSpeed = 0; + + float rate = Time.deltaTime * MoveSpeed; + float distance = Vector3.Distance(transform.position, destinationPosition); + if (distance < rate) + { + transform.position = destinationPosition; + return true; + } + + // If lookatspeed is 0, then set it to max; this method of movement requires + // the gameobject transform to be looking toward it's destination + if (LookAtSpeed <= 0) LookAtSpeed = float.MaxValue; + + UpdateLookAtRotation(); + + Vector3 moveDir = Vector3.forward; + if (XYZConstraint == PositionConstraint.XY) + { + moveDir = Vector3.up; + } + + transform.Translate(moveDir * rate); + + return false; + + } + + /// + /// Rotate the traveler to "look" at the next waypoint. + /// Note: When using the FORWARD_TRANSLATE movement mode, LookAtSpeed is always > 0 + /// + void UpdateLookAtRotation() + { + // LookatSpeed is 0; no rotating... + if (LookAtSpeed <= 0) return; + + float step = LookAtSpeed * Time.deltaTime; + Vector3 targetDir = nextPosition - transform.position; + + + if (XYZConstraint == PositionConstraint.XY) + { + float angle = Mathf.Atan2(targetDir.y, targetDir.x) * Mathf.Rad2Deg - 90; + Quaternion qt = Quaternion.AngleAxis(angle, Vector3.forward); + transform.rotation = Quaternion.RotateTowards(transform.rotation, qt, step); + } + + else if (XYZConstraint == PositionConstraint.XZ) + { + float angle = Mathf.Atan2(targetDir.x, targetDir.z) * Mathf.Rad2Deg; + Quaternion qt = Quaternion.AngleAxis(angle, Vector3.up); + transform.rotation = Quaternion.RotateTowards(transform.rotation, qt, step); + } + else + { + Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0f); + // Move our position a step closer to the target. + transform.rotation = Quaternion.LookRotation(newDir); + + } + + } + +} \ No newline at end of file diff --git a/Assets/Scripts/Waypoints/WaypointsTraveler.cs.meta b/Assets/Scripts/Waypoints/WaypointsTraveler.cs.meta new file mode 100644 index 00000000..1a112db1 --- /dev/null +++ b/Assets/Scripts/Waypoints/WaypointsTraveler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4650cc3407a19a941a6c01a1ddbc876c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: