diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 837f323..92a7f8d 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -123,6 +123,87 @@ debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &14297888 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 14297889} + - component: {fileID: 14297892} + - component: {fileID: 14297891} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &14297889 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 2, y: 0.2, z: 0.2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &14297891 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &14297892 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &128843414 GameObject: m_ObjectHideFlags: 0 @@ -166,9 +247,9 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &683864801 +--- !u!1 &581008541 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -176,92 +257,29 @@ m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 683864805} - - component: {fileID: 683864804} - - component: {fileID: 683864803} - - component: {fileID: 683864802} - m_Layer: 2 - m_Name: Cursor + - component: {fileID: 581008542} + m_Layer: 0 + m_Name: root m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!135 &683864802 -SphereCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Radius: 0.5 - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &683864803 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Enabled: 0 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &683864804 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &683864805 +--- !u!4 &581008542 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} + m_GameObject: {fileID: 581008541} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} - m_Children: [] + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1409854103} + - {fileID: 14297889} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705507993 GameObject: @@ -274,7 +292,7 @@ - component: {fileID: 705507995} - component: {fileID: 705507994} m_Layer: 0 - m_Name: Directional Light + m_Name: sun m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -534,7 +552,7 @@ m_LocalScale: {x: 100, y: 1, z: 100} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &978069801 BoxCollider: @@ -594,12 +612,90 @@ m_Name: m_EditorClassIdentifier: mouseSensitivity: 5 - scrollSpeed: 2 - groundSize: 5 + movementSpeed: 0.1 mainCamera: {fileID: 963194227} - cursor: {fileID: 683864801} roads: {fileID: 1714391591} - cursorPosition: {x: 0, y: 0, z: 0} +--- !u!1 &1409854102 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1409854103} + - component: {fileID: 1409854106} + - component: {fileID: 1409854105} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1409854103 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.2, y: 0.2, z: 2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1409854105 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1409854106 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1714391591 GameObject: m_ObjectHideFlags: 0 @@ -629,7 +725,7 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1714391594 MonoBehaviour: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 837f323..92a7f8d 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -123,6 +123,87 @@ debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &14297888 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 14297889} + - component: {fileID: 14297892} + - component: {fileID: 14297891} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &14297889 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 2, y: 0.2, z: 0.2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &14297891 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &14297892 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &128843414 GameObject: m_ObjectHideFlags: 0 @@ -166,9 +247,9 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &683864801 +--- !u!1 &581008541 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -176,92 +257,29 @@ m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 683864805} - - component: {fileID: 683864804} - - component: {fileID: 683864803} - - component: {fileID: 683864802} - m_Layer: 2 - m_Name: Cursor + - component: {fileID: 581008542} + m_Layer: 0 + m_Name: root m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!135 &683864802 -SphereCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Radius: 0.5 - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &683864803 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Enabled: 0 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &683864804 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &683864805 +--- !u!4 &581008542 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} + m_GameObject: {fileID: 581008541} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} - m_Children: [] + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1409854103} + - {fileID: 14297889} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705507993 GameObject: @@ -274,7 +292,7 @@ - component: {fileID: 705507995} - component: {fileID: 705507994} m_Layer: 0 - m_Name: Directional Light + m_Name: sun m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -534,7 +552,7 @@ m_LocalScale: {x: 100, y: 1, z: 100} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &978069801 BoxCollider: @@ -594,12 +612,90 @@ m_Name: m_EditorClassIdentifier: mouseSensitivity: 5 - scrollSpeed: 2 - groundSize: 5 + movementSpeed: 0.1 mainCamera: {fileID: 963194227} - cursor: {fileID: 683864801} roads: {fileID: 1714391591} - cursorPosition: {x: 0, y: 0, z: 0} +--- !u!1 &1409854102 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1409854103} + - component: {fileID: 1409854106} + - component: {fileID: 1409854105} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1409854103 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.2, y: 0.2, z: 2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1409854105 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1409854106 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1714391591 GameObject: m_ObjectHideFlags: 0 @@ -629,7 +725,7 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1714391594 MonoBehaviour: diff --git a/Assets/Scripts/CameraControl.cs b/Assets/Scripts/CameraControl.cs index 81186f8..b6d8f38 100644 --- a/Assets/Scripts/CameraControl.cs +++ b/Assets/Scripts/CameraControl.cs @@ -8,18 +8,11 @@ [DllImport("user32.dll")] static extern bool SetCursorPos(int X, int Y); - public float mouseSensitivity = 1.0f; - private float pitch = 10.0f; - private float yaw = 0.0f; - private float scale = 0.0f; - public float scrollSpeed = 2.0f; - - public float groundSize = 5.0f; + public float mouseSensitivity = 1.0f, movementSpeed = 0.1f; + private float pitch = 10.0f, yaw = 0.0f, scale = 0.0f, scrollSpeed = 2.0f; public Camera mainCamera; - public GameObject cursor; public GameObject roads; - public Vector3 cursorPosition = new Vector3(); void Start() { } @@ -30,10 +23,18 @@ if (moving) { float dx = Input.GetAxis("Mouse X") * mouseSensitivity; float dy = Input.GetAxis("Mouse Y") * mouseSensitivity; - pitch -= dy; - yaw += dx; - pitch = Mathf.Clamp(pitch, 10, 80); - transform.eulerAngles = new Vector3(pitch, yaw, 0); + if (Input.GetAxis("Jump") != 0.0f) { + Vector3 direction = new Vector3(mainCamera.transform.forward.x, 0.0f, mainCamera.transform.forward.z); + direction.Normalize(); + transform.position -= direction * movementSpeed * dy; + Vector3 normal = new Vector3(direction.z, 0.0f, -direction.x); + transform.position -= normal * movementSpeed * dx; + } else { + pitch -= dy; + yaw += dx; + pitch = Mathf.Clamp(pitch, 10, 80); + transform.eulerAngles = new Vector3(pitch, yaw, 0); + } } float scroll = Input.GetAxis("Mouse ScrollWheel"); if (scroll != 0.0f) { @@ -42,13 +43,5 @@ float realScale = Mathf.Pow(2, scale); transform.localScale = new Vector3(realScale, realScale, realScale); } - Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); - if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, 1 << 6)) { - Vector3 position = new Vector3( - Mathf.Clamp(hit.point.x, -groundSize, groundSize), 0.0f, - Mathf.Clamp(hit.point.z, -groundSize, groundSize)); - cursor.transform.position = position; - cursorPosition = position; - } } } diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 837f323..92a7f8d 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -123,6 +123,87 @@ debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &14297888 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 14297889} + - component: {fileID: 14297892} + - component: {fileID: 14297891} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &14297889 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 2, y: 0.2, z: 0.2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &14297891 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &14297892 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &128843414 GameObject: m_ObjectHideFlags: 0 @@ -166,9 +247,9 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &683864801 +--- !u!1 &581008541 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -176,92 +257,29 @@ m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 683864805} - - component: {fileID: 683864804} - - component: {fileID: 683864803} - - component: {fileID: 683864802} - m_Layer: 2 - m_Name: Cursor + - component: {fileID: 581008542} + m_Layer: 0 + m_Name: root m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!135 &683864802 -SphereCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Radius: 0.5 - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &683864803 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Enabled: 0 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &683864804 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &683864805 +--- !u!4 &581008542 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} + m_GameObject: {fileID: 581008541} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} - m_Children: [] + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1409854103} + - {fileID: 14297889} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705507993 GameObject: @@ -274,7 +292,7 @@ - component: {fileID: 705507995} - component: {fileID: 705507994} m_Layer: 0 - m_Name: Directional Light + m_Name: sun m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -534,7 +552,7 @@ m_LocalScale: {x: 100, y: 1, z: 100} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &978069801 BoxCollider: @@ -594,12 +612,90 @@ m_Name: m_EditorClassIdentifier: mouseSensitivity: 5 - scrollSpeed: 2 - groundSize: 5 + movementSpeed: 0.1 mainCamera: {fileID: 963194227} - cursor: {fileID: 683864801} roads: {fileID: 1714391591} - cursorPosition: {x: 0, y: 0, z: 0} +--- !u!1 &1409854102 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1409854103} + - component: {fileID: 1409854106} + - component: {fileID: 1409854105} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1409854103 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.2, y: 0.2, z: 2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1409854105 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1409854106 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1714391591 GameObject: m_ObjectHideFlags: 0 @@ -629,7 +725,7 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1714391594 MonoBehaviour: diff --git a/Assets/Scripts/CameraControl.cs b/Assets/Scripts/CameraControl.cs index 81186f8..b6d8f38 100644 --- a/Assets/Scripts/CameraControl.cs +++ b/Assets/Scripts/CameraControl.cs @@ -8,18 +8,11 @@ [DllImport("user32.dll")] static extern bool SetCursorPos(int X, int Y); - public float mouseSensitivity = 1.0f; - private float pitch = 10.0f; - private float yaw = 0.0f; - private float scale = 0.0f; - public float scrollSpeed = 2.0f; - - public float groundSize = 5.0f; + public float mouseSensitivity = 1.0f, movementSpeed = 0.1f; + private float pitch = 10.0f, yaw = 0.0f, scale = 0.0f, scrollSpeed = 2.0f; public Camera mainCamera; - public GameObject cursor; public GameObject roads; - public Vector3 cursorPosition = new Vector3(); void Start() { } @@ -30,10 +23,18 @@ if (moving) { float dx = Input.GetAxis("Mouse X") * mouseSensitivity; float dy = Input.GetAxis("Mouse Y") * mouseSensitivity; - pitch -= dy; - yaw += dx; - pitch = Mathf.Clamp(pitch, 10, 80); - transform.eulerAngles = new Vector3(pitch, yaw, 0); + if (Input.GetAxis("Jump") != 0.0f) { + Vector3 direction = new Vector3(mainCamera.transform.forward.x, 0.0f, mainCamera.transform.forward.z); + direction.Normalize(); + transform.position -= direction * movementSpeed * dy; + Vector3 normal = new Vector3(direction.z, 0.0f, -direction.x); + transform.position -= normal * movementSpeed * dx; + } else { + pitch -= dy; + yaw += dx; + pitch = Mathf.Clamp(pitch, 10, 80); + transform.eulerAngles = new Vector3(pitch, yaw, 0); + } } float scroll = Input.GetAxis("Mouse ScrollWheel"); if (scroll != 0.0f) { @@ -42,13 +43,5 @@ float realScale = Mathf.Pow(2, scale); transform.localScale = new Vector3(realScale, realScale, realScale); } - Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); - if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, 1 << 6)) { - Vector3 position = new Vector3( - Mathf.Clamp(hit.point.x, -groundSize, groundSize), 0.0f, - Mathf.Clamp(hit.point.z, -groundSize, groundSize)); - cursor.transform.position = position; - cursorPosition = position; - } } } diff --git a/Assets/Scripts/Node.cs b/Assets/Scripts/Node.cs index 651f40e..e3c4cbd 100644 --- a/Assets/Scripts/Node.cs +++ b/Assets/Scripts/Node.cs @@ -14,7 +14,7 @@ gameObject = new GameObject(); gameObject.transform.position = position; gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 0.25f; + gameObject.AddComponent().radius = 0.5f; gameObject.layer = 7; GameObject nodeCircle = new GameObject(); diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 837f323..92a7f8d 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -123,6 +123,87 @@ debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &14297888 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 14297889} + - component: {fileID: 14297892} + - component: {fileID: 14297891} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &14297889 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 2, y: 0.2, z: 0.2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &14297891 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &14297892 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &128843414 GameObject: m_ObjectHideFlags: 0 @@ -166,9 +247,9 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &683864801 +--- !u!1 &581008541 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -176,92 +257,29 @@ m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 683864805} - - component: {fileID: 683864804} - - component: {fileID: 683864803} - - component: {fileID: 683864802} - m_Layer: 2 - m_Name: Cursor + - component: {fileID: 581008542} + m_Layer: 0 + m_Name: root m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!135 &683864802 -SphereCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Radius: 0.5 - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &683864803 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Enabled: 0 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &683864804 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &683864805 +--- !u!4 &581008542 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} + m_GameObject: {fileID: 581008541} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} - m_Children: [] + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1409854103} + - {fileID: 14297889} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705507993 GameObject: @@ -274,7 +292,7 @@ - component: {fileID: 705507995} - component: {fileID: 705507994} m_Layer: 0 - m_Name: Directional Light + m_Name: sun m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -534,7 +552,7 @@ m_LocalScale: {x: 100, y: 1, z: 100} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &978069801 BoxCollider: @@ -594,12 +612,90 @@ m_Name: m_EditorClassIdentifier: mouseSensitivity: 5 - scrollSpeed: 2 - groundSize: 5 + movementSpeed: 0.1 mainCamera: {fileID: 963194227} - cursor: {fileID: 683864801} roads: {fileID: 1714391591} - cursorPosition: {x: 0, y: 0, z: 0} +--- !u!1 &1409854102 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1409854103} + - component: {fileID: 1409854106} + - component: {fileID: 1409854105} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1409854103 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.2, y: 0.2, z: 2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1409854105 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1409854106 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1714391591 GameObject: m_ObjectHideFlags: 0 @@ -629,7 +725,7 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1714391594 MonoBehaviour: diff --git a/Assets/Scripts/CameraControl.cs b/Assets/Scripts/CameraControl.cs index 81186f8..b6d8f38 100644 --- a/Assets/Scripts/CameraControl.cs +++ b/Assets/Scripts/CameraControl.cs @@ -8,18 +8,11 @@ [DllImport("user32.dll")] static extern bool SetCursorPos(int X, int Y); - public float mouseSensitivity = 1.0f; - private float pitch = 10.0f; - private float yaw = 0.0f; - private float scale = 0.0f; - public float scrollSpeed = 2.0f; - - public float groundSize = 5.0f; + public float mouseSensitivity = 1.0f, movementSpeed = 0.1f; + private float pitch = 10.0f, yaw = 0.0f, scale = 0.0f, scrollSpeed = 2.0f; public Camera mainCamera; - public GameObject cursor; public GameObject roads; - public Vector3 cursorPosition = new Vector3(); void Start() { } @@ -30,10 +23,18 @@ if (moving) { float dx = Input.GetAxis("Mouse X") * mouseSensitivity; float dy = Input.GetAxis("Mouse Y") * mouseSensitivity; - pitch -= dy; - yaw += dx; - pitch = Mathf.Clamp(pitch, 10, 80); - transform.eulerAngles = new Vector3(pitch, yaw, 0); + if (Input.GetAxis("Jump") != 0.0f) { + Vector3 direction = new Vector3(mainCamera.transform.forward.x, 0.0f, mainCamera.transform.forward.z); + direction.Normalize(); + transform.position -= direction * movementSpeed * dy; + Vector3 normal = new Vector3(direction.z, 0.0f, -direction.x); + transform.position -= normal * movementSpeed * dx; + } else { + pitch -= dy; + yaw += dx; + pitch = Mathf.Clamp(pitch, 10, 80); + transform.eulerAngles = new Vector3(pitch, yaw, 0); + } } float scroll = Input.GetAxis("Mouse ScrollWheel"); if (scroll != 0.0f) { @@ -42,13 +43,5 @@ float realScale = Mathf.Pow(2, scale); transform.localScale = new Vector3(realScale, realScale, realScale); } - Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); - if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, 1 << 6)) { - Vector3 position = new Vector3( - Mathf.Clamp(hit.point.x, -groundSize, groundSize), 0.0f, - Mathf.Clamp(hit.point.z, -groundSize, groundSize)); - cursor.transform.position = position; - cursorPosition = position; - } } } diff --git a/Assets/Scripts/Node.cs b/Assets/Scripts/Node.cs index 651f40e..e3c4cbd 100644 --- a/Assets/Scripts/Node.cs +++ b/Assets/Scripts/Node.cs @@ -14,7 +14,7 @@ gameObject = new GameObject(); gameObject.transform.position = position; gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 0.25f; + gameObject.AddComponent().radius = 0.5f; gameObject.layer = 7; GameObject nodeCircle = new GameObject(); diff --git a/Assets/Scripts/Road.cs b/Assets/Scripts/Road.cs index 7250559..3d3f5bf 100644 --- a/Assets/Scripts/Road.cs +++ b/Assets/Scripts/Road.cs @@ -26,10 +26,14 @@ lineChild.AddComponent().mesh = pathLine.mesh; lineChild.transform.parent = parent; GameObject roadChild = new GameObject(); + roadChild.transform.position = Vector3.zero; roadChild.AddComponent().material = config.roadMaterial; - roadChild.AddComponent().mesh = roadBody.mesh; roadChild.transform.parent = parent; + roadChild.layer = 8; + roadChild.AddComponent(); + roadChild.AddComponent().mesh = roadBody.mesh; + update(true); } diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 837f323..92a7f8d 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -123,6 +123,87 @@ debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &14297888 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 14297889} + - component: {fileID: 14297892} + - component: {fileID: 14297891} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &14297889 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 2, y: 0.2, z: 0.2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &14297891 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &14297892 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &128843414 GameObject: m_ObjectHideFlags: 0 @@ -166,9 +247,9 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &683864801 +--- !u!1 &581008541 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -176,92 +257,29 @@ m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 683864805} - - component: {fileID: 683864804} - - component: {fileID: 683864803} - - component: {fileID: 683864802} - m_Layer: 2 - m_Name: Cursor + - component: {fileID: 581008542} + m_Layer: 0 + m_Name: root m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!135 &683864802 -SphereCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Radius: 0.5 - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &683864803 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Enabled: 0 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &683864804 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &683864805 +--- !u!4 &581008542 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} + m_GameObject: {fileID: 581008541} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} - m_Children: [] + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1409854103} + - {fileID: 14297889} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705507993 GameObject: @@ -274,7 +292,7 @@ - component: {fileID: 705507995} - component: {fileID: 705507994} m_Layer: 0 - m_Name: Directional Light + m_Name: sun m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -534,7 +552,7 @@ m_LocalScale: {x: 100, y: 1, z: 100} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &978069801 BoxCollider: @@ -594,12 +612,90 @@ m_Name: m_EditorClassIdentifier: mouseSensitivity: 5 - scrollSpeed: 2 - groundSize: 5 + movementSpeed: 0.1 mainCamera: {fileID: 963194227} - cursor: {fileID: 683864801} roads: {fileID: 1714391591} - cursorPosition: {x: 0, y: 0, z: 0} +--- !u!1 &1409854102 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1409854103} + - component: {fileID: 1409854106} + - component: {fileID: 1409854105} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1409854103 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.2, y: 0.2, z: 2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1409854105 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1409854106 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1714391591 GameObject: m_ObjectHideFlags: 0 @@ -629,7 +725,7 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1714391594 MonoBehaviour: diff --git a/Assets/Scripts/CameraControl.cs b/Assets/Scripts/CameraControl.cs index 81186f8..b6d8f38 100644 --- a/Assets/Scripts/CameraControl.cs +++ b/Assets/Scripts/CameraControl.cs @@ -8,18 +8,11 @@ [DllImport("user32.dll")] static extern bool SetCursorPos(int X, int Y); - public float mouseSensitivity = 1.0f; - private float pitch = 10.0f; - private float yaw = 0.0f; - private float scale = 0.0f; - public float scrollSpeed = 2.0f; - - public float groundSize = 5.0f; + public float mouseSensitivity = 1.0f, movementSpeed = 0.1f; + private float pitch = 10.0f, yaw = 0.0f, scale = 0.0f, scrollSpeed = 2.0f; public Camera mainCamera; - public GameObject cursor; public GameObject roads; - public Vector3 cursorPosition = new Vector3(); void Start() { } @@ -30,10 +23,18 @@ if (moving) { float dx = Input.GetAxis("Mouse X") * mouseSensitivity; float dy = Input.GetAxis("Mouse Y") * mouseSensitivity; - pitch -= dy; - yaw += dx; - pitch = Mathf.Clamp(pitch, 10, 80); - transform.eulerAngles = new Vector3(pitch, yaw, 0); + if (Input.GetAxis("Jump") != 0.0f) { + Vector3 direction = new Vector3(mainCamera.transform.forward.x, 0.0f, mainCamera.transform.forward.z); + direction.Normalize(); + transform.position -= direction * movementSpeed * dy; + Vector3 normal = new Vector3(direction.z, 0.0f, -direction.x); + transform.position -= normal * movementSpeed * dx; + } else { + pitch -= dy; + yaw += dx; + pitch = Mathf.Clamp(pitch, 10, 80); + transform.eulerAngles = new Vector3(pitch, yaw, 0); + } } float scroll = Input.GetAxis("Mouse ScrollWheel"); if (scroll != 0.0f) { @@ -42,13 +43,5 @@ float realScale = Mathf.Pow(2, scale); transform.localScale = new Vector3(realScale, realScale, realScale); } - Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); - if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, 1 << 6)) { - Vector3 position = new Vector3( - Mathf.Clamp(hit.point.x, -groundSize, groundSize), 0.0f, - Mathf.Clamp(hit.point.z, -groundSize, groundSize)); - cursor.transform.position = position; - cursorPosition = position; - } } } diff --git a/Assets/Scripts/Node.cs b/Assets/Scripts/Node.cs index 651f40e..e3c4cbd 100644 --- a/Assets/Scripts/Node.cs +++ b/Assets/Scripts/Node.cs @@ -14,7 +14,7 @@ gameObject = new GameObject(); gameObject.transform.position = position; gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 0.25f; + gameObject.AddComponent().radius = 0.5f; gameObject.layer = 7; GameObject nodeCircle = new GameObject(); diff --git a/Assets/Scripts/Road.cs b/Assets/Scripts/Road.cs index 7250559..3d3f5bf 100644 --- a/Assets/Scripts/Road.cs +++ b/Assets/Scripts/Road.cs @@ -26,10 +26,14 @@ lineChild.AddComponent().mesh = pathLine.mesh; lineChild.transform.parent = parent; GameObject roadChild = new GameObject(); + roadChild.transform.position = Vector3.zero; roadChild.AddComponent().material = config.roadMaterial; - roadChild.AddComponent().mesh = roadBody.mesh; roadChild.transform.parent = parent; + roadChild.layer = 8; + roadChild.AddComponent(); + roadChild.AddComponent().mesh = roadBody.mesh; + update(true); } diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 17c8f53..9f236a1 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -74,7 +74,7 @@ descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: left shift + positiveButton: altNegativeButton: altPositiveButton: mouse 2 gravity: 1000 @@ -90,7 +90,7 @@ descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: space + positiveButton: left shift altNegativeButton: altPositiveButton: gravity: 1000 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 837f323..92a7f8d 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -123,6 +123,87 @@ debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &14297888 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 14297889} + - component: {fileID: 14297892} + - component: {fileID: 14297891} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &14297889 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 2, y: 0.2, z: 0.2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &14297891 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &14297892 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14297888} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &128843414 GameObject: m_ObjectHideFlags: 0 @@ -166,9 +247,9 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &683864801 +--- !u!1 &581008541 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -176,92 +257,29 @@ m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 683864805} - - component: {fileID: 683864804} - - component: {fileID: 683864803} - - component: {fileID: 683864802} - m_Layer: 2 - m_Name: Cursor + - component: {fileID: 581008542} + m_Layer: 0 + m_Name: root m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!135 &683864802 -SphereCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Radius: 0.5 - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &683864803 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Enabled: 0 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &683864804 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &683864805 +--- !u!4 &581008542 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 683864801} + m_GameObject: {fileID: 581008541} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} - m_Children: [] + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1409854103} + - {fileID: 14297889} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705507993 GameObject: @@ -274,7 +292,7 @@ - component: {fileID: 705507995} - component: {fileID: 705507994} m_Layer: 0 - m_Name: Directional Light + m_Name: sun m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -534,7 +552,7 @@ m_LocalScale: {x: 100, y: 1, z: 100} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &978069801 BoxCollider: @@ -594,12 +612,90 @@ m_Name: m_EditorClassIdentifier: mouseSensitivity: 5 - scrollSpeed: 2 - groundSize: 5 + movementSpeed: 0.1 mainCamera: {fileID: 963194227} - cursor: {fileID: 683864801} roads: {fileID: 1714391591} - cursorPosition: {x: 0, y: 0, z: 0} +--- !u!1 &1409854102 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1409854103} + - component: {fileID: 1409854106} + - component: {fileID: 1409854105} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1409854103 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.2, y: 0.2, z: 2} + m_Children: [] + m_Father: {fileID: 581008542} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1409854105 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1409854106 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1409854102} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1714391591 GameObject: m_ObjectHideFlags: 0 @@ -629,7 +725,7 @@ m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1714391594 MonoBehaviour: diff --git a/Assets/Scripts/CameraControl.cs b/Assets/Scripts/CameraControl.cs index 81186f8..b6d8f38 100644 --- a/Assets/Scripts/CameraControl.cs +++ b/Assets/Scripts/CameraControl.cs @@ -8,18 +8,11 @@ [DllImport("user32.dll")] static extern bool SetCursorPos(int X, int Y); - public float mouseSensitivity = 1.0f; - private float pitch = 10.0f; - private float yaw = 0.0f; - private float scale = 0.0f; - public float scrollSpeed = 2.0f; - - public float groundSize = 5.0f; + public float mouseSensitivity = 1.0f, movementSpeed = 0.1f; + private float pitch = 10.0f, yaw = 0.0f, scale = 0.0f, scrollSpeed = 2.0f; public Camera mainCamera; - public GameObject cursor; public GameObject roads; - public Vector3 cursorPosition = new Vector3(); void Start() { } @@ -30,10 +23,18 @@ if (moving) { float dx = Input.GetAxis("Mouse X") * mouseSensitivity; float dy = Input.GetAxis("Mouse Y") * mouseSensitivity; - pitch -= dy; - yaw += dx; - pitch = Mathf.Clamp(pitch, 10, 80); - transform.eulerAngles = new Vector3(pitch, yaw, 0); + if (Input.GetAxis("Jump") != 0.0f) { + Vector3 direction = new Vector3(mainCamera.transform.forward.x, 0.0f, mainCamera.transform.forward.z); + direction.Normalize(); + transform.position -= direction * movementSpeed * dy; + Vector3 normal = new Vector3(direction.z, 0.0f, -direction.x); + transform.position -= normal * movementSpeed * dx; + } else { + pitch -= dy; + yaw += dx; + pitch = Mathf.Clamp(pitch, 10, 80); + transform.eulerAngles = new Vector3(pitch, yaw, 0); + } } float scroll = Input.GetAxis("Mouse ScrollWheel"); if (scroll != 0.0f) { @@ -42,13 +43,5 @@ float realScale = Mathf.Pow(2, scale); transform.localScale = new Vector3(realScale, realScale, realScale); } - Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); - if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, 1 << 6)) { - Vector3 position = new Vector3( - Mathf.Clamp(hit.point.x, -groundSize, groundSize), 0.0f, - Mathf.Clamp(hit.point.z, -groundSize, groundSize)); - cursor.transform.position = position; - cursorPosition = position; - } } } diff --git a/Assets/Scripts/Node.cs b/Assets/Scripts/Node.cs index 651f40e..e3c4cbd 100644 --- a/Assets/Scripts/Node.cs +++ b/Assets/Scripts/Node.cs @@ -14,7 +14,7 @@ gameObject = new GameObject(); gameObject.transform.position = position; gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 0.25f; + gameObject.AddComponent().radius = 0.5f; gameObject.layer = 7; GameObject nodeCircle = new GameObject(); diff --git a/Assets/Scripts/Road.cs b/Assets/Scripts/Road.cs index 7250559..3d3f5bf 100644 --- a/Assets/Scripts/Road.cs +++ b/Assets/Scripts/Road.cs @@ -26,10 +26,14 @@ lineChild.AddComponent().mesh = pathLine.mesh; lineChild.transform.parent = parent; GameObject roadChild = new GameObject(); + roadChild.transform.position = Vector3.zero; roadChild.AddComponent().material = config.roadMaterial; - roadChild.AddComponent().mesh = roadBody.mesh; roadChild.transform.parent = parent; + roadChild.layer = 8; + roadChild.AddComponent(); + roadChild.AddComponent().mesh = roadBody.mesh; + update(true); } diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 17c8f53..9f236a1 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -74,7 +74,7 @@ descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: left shift + positiveButton: altNegativeButton: altPositiveButton: mouse 2 gravity: 1000 @@ -90,7 +90,7 @@ descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: space + positiveButton: left shift altNegativeButton: altPositiveButton: gravity: 1000 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 7c3efe3..96ed5f8 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -13,7 +13,7 @@ - UI - Ground - RoadEdit - - + - RoadCollide - - -