From d66c583f0082fca4e6f2c6384dd8827dd322d801 Mon Sep 17 00:00:00 2001 From: bozmir Date: Tue, 17 Dec 2024 17:45:48 +0100 Subject: [PATCH] some fixes for controlls and coordinates --- .../Runtime/Events/JumpInput.asset | 16 + .../Runtime/Events/JumpInput.asset.meta | 8 + .../Input/CameraInputActions.inputactions | 20 + .../Input/CameraInputSystemProvider.cs | 14 +- Assets/Scenes/Main.unity | 16 +- .../KerstSpecial/20120210 Elfstedentocht.txt | 5378 +++++++++++++++++ .../20120210 Elfstedentocht.txt.meta | 7 + Assets/Scripts/KerstSpecial/RaceController.cs | 137 +- 8 files changed, 5568 insertions(+), 28 deletions(-) create mode 100644 Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Events/JumpInput.asset create mode 100644 Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Events/JumpInput.asset.meta create mode 100644 Assets/Scripts/KerstSpecial/20120210 Elfstedentocht.txt create mode 100644 Assets/Scripts/KerstSpecial/20120210 Elfstedentocht.txt.meta diff --git a/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Events/JumpInput.asset b/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Events/JumpInput.asset new file mode 100644 index 000000000..c55a09501 --- /dev/null +++ b/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Events/JumpInput.asset @@ -0,0 +1,16 @@ +%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: cb96d9d462cb74a419a01a4c68a90f32, type: 3} + m_Name: JumpInput + m_EditorClassIdentifier: + eventName: + description: diff --git a/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Events/JumpInput.asset.meta b/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Events/JumpInput.asset.meta new file mode 100644 index 000000000..20105eb4e --- /dev/null +++ b/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Events/JumpInput.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46da008daaac56f4c97ac21469b742b5 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Input/CameraInputActions.inputactions b/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Input/CameraInputActions.inputactions index 29c83ecc5..3a875dff8 100644 --- a/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Input/CameraInputActions.inputactions +++ b/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Input/CameraInputActions.inputactions @@ -94,6 +94,15 @@ "processors": "", "interactions": "", "initialStateCheck": true + }, + { + "name": "Jump", + "type": "Button", + "id": "5a7bd737-7287-436f-bbfd-74b808421bf8", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -448,6 +457,17 @@ "action": "Fly", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "eb3034d1-6238-4c5e-8254-e9769086a0a2", + "path": "/space", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Jump", + "isComposite": false, + "isPartOfComposite": false } ] }, diff --git a/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Scripts/Input/CameraInputSystemProvider.cs b/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Scripts/Input/CameraInputSystemProvider.cs index 688584b9a..6f3a19138 100644 --- a/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Scripts/Input/CameraInputSystemProvider.cs +++ b/Assets/PackageStagingArea/eu.netherlands3d.cameras/Runtime/Scripts/Input/CameraInputSystemProvider.cs @@ -9,6 +9,7 @@ #if ENABLE_INPUT_SYSTEM using UnityEngine.InputSystem; using UnityEngine.InputSystem.UI; +using Netherlands3D.Events; #endif /* Copyright(C) X Gemeente @@ -43,12 +44,14 @@ public class CameraInputSystemProvider : BaseCameraInputProvider private InputAction upAction; private InputAction downAction; private InputAction zoomAction; - + private InputAction jumpAction; private InputAction rotateModifierAction; private InputAction firstPersonModifierAction; private InputAction pointerAction; + public BoolEvent jumpEvent; + private InputSystemUIInputModule inputSystemUIInputModule; private float previousPinchDistance = 0; @@ -126,6 +129,7 @@ private void Awake() rotateModifierAction = cameraActionMap.FindAction("RotateModifier"); firstPersonModifierAction = cameraActionMap.FindAction("FirstPersonModifier"); pointerAction = cameraActionMap.FindAction("Point"); + jumpAction = cameraActionMap.FindAction("Jump"); SetOriginalProcessors(zoomAction); #if !UNITY_EDITOR @@ -207,6 +211,8 @@ public void Update() var upPressed = upAction.IsPressed(); var downPressed = downAction.IsPressed(); + var jumpPressed = jumpAction.IsPressed(); + //If there is a secondary input, convert pinch into zoom var secondaryPointerPosition = secondaryDragAction.ReadValue(); var draggingSecondary = !lockDraggingInput && secondaryPointerPosition.magnitude > 0; @@ -288,6 +294,7 @@ public void Update() //Invoke values as events InvokeEvents(dragging, moveValue, lookValue, zoomValue, flyValue, rotateValue, upPressed, downPressed); + InvokeJumpEvent(jumpPressed); } private void InvokeEvents(bool dragging, Vector2 moveValue, Vector2 lookValue, Vector2 zoomValue, Vector2 flyValue, Vector2 rotateValue, bool upPressed, bool downPressed) @@ -347,6 +354,11 @@ private void InvokeEvents(bool dragging, Vector2 moveValue, Vector2 lookValue, V pauseHeavyProcess.InvokeStarted(requiresSmoothMovement); } + private void InvokeJumpEvent(bool pressed) + { + jumpEvent?.InvokeStarted(pressed); + } + private void OnDrawGizmos() { Camera cam = Camera.main; diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index f0bcc3191..b8188602c 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -1038,6 +1038,8 @@ MonoBehaviour: horizontalInput: {fileID: 11400000, guid: 93242d5c5434ab44c966480e1ff5c8d5, type: 2} verticalInput: {fileID: 11400000, guid: 22faa7b25fade4845812eab67089a12b, type: 2} upDownInput: {fileID: 11400000, guid: 3ff45f65e26c59542a8e4f3772860382, type: 2} + jumpInput: {fileID: 11400000, guid: 46da008daaac56f4c97ac21469b742b5, type: 2} + routeFile: {fileID: 4900000, guid: 3653738e64b9fdb44a2b7a94ac1bfed4, type: 3} --- !u!1 &816029622 GameObject: m_ObjectHideFlags: 0 @@ -2432,6 +2434,12 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 2142188160281320149, guid: 0f6ad95dabe72044aa90eb8ae2e45366, + type: 3} + propertyPath: jumpEvent + value: + objectReference: {fileID: 11400000, guid: 46da008daaac56f4c97ac21469b742b5, + type: 2} - target: {fileID: 5315891981602308679, guid: 0f6ad95dabe72044aa90eb8ae2e45366, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -2494,22 +2502,22 @@ PrefabInstance: - target: {fileID: 3849934062868920522, guid: 5fbb7c7c8ec47e849afba1b658f3e07e, type: 3} propertyPath: m_LocalRotation.w - value: 0.19873667 + value: 0.19865541 objectReference: {fileID: 0} - target: {fileID: 3849934062868920522, guid: 5fbb7c7c8ec47e849afba1b658f3e07e, type: 3} propertyPath: m_LocalRotation.x - value: 0.08302961 + value: 0.082976505 objectReference: {fileID: 0} - target: {fileID: 3849934062868920522, guid: 5fbb7c7c8ec47e849afba1b658f3e07e, type: 3} propertyPath: m_LocalRotation.y - value: 0.901053 + value: 0.9011034 objectReference: {fileID: 0} - target: {fileID: 3849934062868920522, guid: 5fbb7c7c8ec47e849afba1b658f3e07e, type: 3} propertyPath: m_LocalRotation.z - value: -0.3764483 + value: -0.37638244 objectReference: {fileID: 0} - target: {fileID: 3919916255551741050, guid: 5fbb7c7c8ec47e849afba1b658f3e07e, type: 3} diff --git a/Assets/Scripts/KerstSpecial/20120210 Elfstedentocht.txt b/Assets/Scripts/KerstSpecial/20120210 Elfstedentocht.txt new file mode 100644 index 000000000..fe441f884 --- /dev/null +++ b/Assets/Scripts/KerstSpecial/20120210 Elfstedentocht.txt @@ -0,0 +1,5378 @@ + + + ACTIVE LOG072542 + + + -2.887000 + + + + -3.222000 + + + + -3.063000 + + + + -3.290000 + + + + -3.524000 + + + + -3.843000 + + + + -4.252000 + + + + -3.294000 + + + + -3.141000 + + + + -4.199000 + + + + -4.324000 + + + + -4.055000 + + + + -4.664000 + + + + -4.669000 + + + + -5.356000 + + + + -6.260000 + + + + -6.473000 + + + + -6.406000 + + + + -6.544000 + + + + -6.424000 + + + + -6.044000 + + + + -5.779000 + + + + -5.757000 + + + + -5.661000 + + + + -5.585000 + + + + -5.741000 + + + + -6.447000 + + + + -6.885000 + + + + -6.832000 + + + + -7.160000 + + + + -7.522000 + + + + -7.782000 + + + + -7.524000 + + + + -7.925000 + + + + -7.441000 + + + + -7.299000 + + + + -7.931000 + + + + -6.896000 + + + + -7.479000 + + + + -7.419000 + + + + -6.269000 + + + + -7.480000 + + + + -6.588000 + + + + -7.167000 + + + + -6.686000 + + + + -6.866000 + + + + -6.992000 + + + + -6.464000 + + + + -6.453000 + + + + -6.020000 + + + + -6.019000 + + + + -6.095000 + + + + -0.276000 + + + + -6.943000 + + + + -6.454000 + + + + -6.312000 + + + + -5.737000 + + + + -6.720000 + + + + -6.075000 + + + + -4.505000 + + + + -5.224000 + + + + -4.614000 + + + + -4.265000 + + + + -4.298000 + + + + -5.117000 + + + + -5.843000 + + + + -5.987000 + + + + -6.123000 + + + + -7.761000 + + + + -7.092000 + + + + -8.971000 + + + + -9.748000 + + + + -7.933000 + + + + -9.982000 + + + + -9.314000 + + + + -11.558000 + + + + -10.772000 + + + + -10.574000 + + + + -11.566000 + + + + -11.033000 + + + + -10.464000 + + + + -11.720000 + + + + -11.355000 + + + + -10.813000 + + + + -9.531000 + + + + -10.129000 + + + + -11.740000 + + + + -10.973000 + + + + -11.088000 + + + + -10.611000 + + + + -10.955000 + + + + -11.212000 + + + + -13.035000 + + + + -12.840000 + + + + -11.917000 + + + + -10.871000 + + + + -11.328000 + + + + -10.524000 + + + + -11.060000 + + + + -10.766000 + + + + -10.752000 + + + + -11.414000 + + + + -10.764000 + + + + -10.402000 + + + + -10.682000 + + + + -9.543000 + + + + -9.526000 + + + + -8.739000 + + + + -11.964000 + + + + -8.247000 + + + + -8.099000 + + + + -7.802000 + + + + -6.681000 + + + + -7.786000 + + + + -5.950000 + + + + -6.787000 + + + + -6.078000 + + + + -7.348000 + + + + -9.486000 + + + + -9.974000 + + + + -10.036000 + + + + -10.286000 + + + + -10.062000 + + + + -11.272000 + + + + -9.296000 + + + + -8.091000 + + + + -10.849000 + + + + -10.824000 + + + + -10.991000 + + + + -10.599000 + + + + -9.938000 + + + + -9.928000 + + + + -8.882000 + + + + -8.684000 + + + + -9.158000 + + + + -8.834000 + + + + -9.174000 + + + + -7.918000 + + + + -8.171000 + + + + -7.721000 + + + + -7.598000 + + + + -7.728000 + + + + -7.383000 + + + + -6.670000 + + + + -7.285000 + + + + -7.892000 + + + + -7.336000 + + + + -7.186000 + + + + -7.605000 + + + + -7.202000 + + + + -7.907000 + + + + -7.632000 + + + + -7.578000 + + + + -7.100000 + + + + -6.368000 + + + + -6.824000 + + + + -7.316000 + + + + -6.405000 + + + + -9.009000 + + + + -10.254000 + + + + -6.412000 + + + + -6.921000 + + + + -8.105000 + + + + -7.172000 + + + + -5.965000 + + + + -5.100000 + + + + -3.589000 + + + + -4.719000 + + + + -4.868000 + + + + -3.812000 + + + + -4.805000 + + + + -7.777000 + + + + -3.805000 + + + + -4.192000 + + + + -6.682000 + + + + -6.739000 + + + + -6.444000 + + + + -6.288000 + + + + -3.988000 + + + + -4.121000 + + + + -6.318000 + + + + -4.831000 + + + + -4.972000 + + + + -9.301000 + + + + -7.178000 + + + + -6.806000 + + + + -9.637000 + + + + -9.938000 + + + + -9.827000 + + + + -4.911000 + + + + -9.843000 + + + + -7.857000 + + + + -7.282000 + + + + -8.409000 + + + + -8.436000 + + + + -9.805000 + + + + -8.555000 + + + + -8.608000 + + + + -7.495000 + + + + -7.099000 + + + + -6.332000 + + + + -7.259000 + + + + -3.062000 + + + + -4.369000 + + + + -7.178000 + + + + -4.717000 + + + + -6.373000 + + + + -5.222000 + + + + -5.335000 + + + + -2.945000 + + + + -3.606000 + + + + -3.736000 + + + + -2.499000 + + + + -3.320000 + + + + -3.164000 + + + + 0.227000 + + + + 2.009000 + + + + -0.961000 + + + + -2.889000 + + + + -2.676000 + + + + -3.964000 + + + + -0.716000 + + + + -1.859000 + + + + -2.734000 + + + + -4.423000 + + + + -6.473000 + + + + -8.139000 + + + + -6.499000 + + + + -6.574000 + + + + -7.043000 + + + + -6.934000 + + + + -8.643000 + + + + -8.094000 + + + + -9.227000 + + + + -9.175000 + + + + -4.058000 + + + + -6.856000 + + + + -10.855000 + + + + -10.574000 + + + + -10.412000 + + + + -8.810000 + + + + -7.694000 + + + + -7.074000 + + + + -7.904000 + + + + -12.041000 + + + + -10.995000 + + + + -10.618000 + + + + -9.804000 + + + + -11.661000 + + + + -10.214000 + + + + -10.681000 + + + + -10.731000 + + + + -10.702000 + + + + -11.070000 + + + + -11.061000 + + + + -8.950000 + + + + -10.140000 + + + + -10.154000 + + + + -9.994000 + + + + -9.647000 + + + + -11.228000 + + + + -10.635000 + + + + -10.297000 + + + + -9.301000 + + + + -10.952000 + + + + -12.339000 + + + + -10.133000 + + + + -11.181000 + + + + -11.562000 + + + + -12.347000 + + + + -11.473000 + + + + -11.641000 + + + + -11.561000 + + + + -10.566000 + + + + -12.829000 + + + + -11.487000 + + + + -10.159000 + + + + -10.351000 + + + + -11.301000 + + + + -10.657000 + + + + -11.457000 + + + + -11.648000 + + + + -11.784000 + + + + -11.177000 + + + + -12.320000 + + + + -11.345000 + + + + -11.145000 + + + + -12.475000 + + + + -10.346000 + + + + -10.635000 + + + + -9.911000 + + + + -10.168000 + + + + -11.377000 + + + + -11.501000 + + + + -11.151000 + + + + -7.287000 + + + + -11.079000 + + + + -9.476000 + + + + -10.089000 + + + + -12.397000 + + + + -9.233000 + + + + -10.774000 + + + + -10.826000 + + + + -11.933000 + + + + -9.303000 + + + + -12.982000 + + + + -11.246000 + + + + -12.360000 + + + + -12.092000 + + + + -12.262000 + + + + -12.507000 + + + + -13.396000 + + + + -14.037000 + + + + -14.355000 + + + + -16.337000 + + + + -14.326000 + + + + -15.003000 + + + + -13.671000 + + + + -10.183000 + + + + -13.511000 + + + + -16.095000 + + + + -15.857000 + + + + -15.965000 + + + + -14.706000 + + + + -15.180000 + + + + -15.313000 + + + + -15.436000 + + + + -15.548000 + + + + -15.545000 + + + + -16.193000 + + + + -15.355000 + + + + -15.016000 + + + + -14.307000 + + + + -15.323000 + + + + -16.086000 + + + + -14.725000 + + + + -14.833000 + + + + -15.547000 + + + + -14.307000 + + + + -13.118000 + + + + -16.168000 + + + + -14.023000 + + + + -13.567000 + + + + -13.880000 + + + + -15.964000 + + + + -13.241000 + + + + -9.777000 + + + + -7.139000 + + + + -7.209000 + + + + -9.115000 + + + + -11.903000 + + + + -10.465000 + + + + -10.270000 + + + + -12.234000 + + + + -11.167000 + + + + -12.468000 + + + + -9.880000 + + + + -9.803000 + + + + -11.880000 + + + + -11.049000 + + + + -13.510000 + + + + -13.401000 + + + + -12.314000 + + + + -11.188000 + + + + -11.629000 + + + + -12.178000 + + + + -11.365000 + + + + -10.548000 + + + + -10.863000 + + + + -13.947000 + + + + -9.812000 + + + + -9.671000 + + + + -10.038000 + + + + -8.875000 + + + + -7.195000 + + + + -9.548000 + + + + -10.318000 + + + + -8.214000 + + + + -9.835000 + + + + -10.674000 + + + + -11.195000 + + + + -12.245000 + + + + -9.987000 + + + + -9.757000 + + + + -11.048000 + + + + -8.723000 + + + + -10.867000 + + + + -11.629000 + + + + -11.536000 + + + + -10.919000 + + + + -10.371000 + + + + -10.640000 + + + + -10.459000 + + + + -9.257000 + + + + -10.474000 + + + + -10.256000 + + + + -8.710000 + + + + -10.723000 + + + + -10.074000 + + + + -11.002000 + + + + + ACTIVE LOG154308 + + + -12.458000 + + + + 8.670000 + + + + -10.915000 + + + + -10.744000 + + + + -9.630000 + + + + -9.538000 + + + + -9.954000 + + + + -10.281000 + + + + -9.456000 + + + + -10.359000 + + + + -10.034000 + + + + -9.715000 + + + + -9.871000 + + + + -9.478000 + + + + -10.228000 + + + + -10.386000 + + + + -10.975000 + + + + -11.630000 + + + + -10.945000 + + + + -11.276000 + + + + -9.784000 + + + + -9.012000 + + + + -10.746000 + + + + -8.408000 + + + + -7.831000 + + + + -8.449000 + + + + -9.339000 + + + + -9.108000 + + + + -8.565000 + + + + -8.524000 + + + + -8.753000 + + + + -8.431000 + + + + -7.683000 + + + + -8.366000 + + + + -8.113000 + + + + -8.997000 + + + + -8.354000 + + + + -8.492000 + + + + -8.075000 + + + + -8.505000 + + + + -9.455000 + + + + -7.809000 + + + + -9.155000 + + + + -8.201000 + + + + -8.030000 + + + + -7.143000 + + + + -7.590000 + + + + -6.820000 + + + + -7.082000 + + + + -7.344000 + + + + -7.604000 + + + + -8.182000 + + + + -8.098000 + + + + -6.536000 + + + + -7.453000 + + + + -6.591000 + + + + -6.988000 + + + + -6.081000 + + + + -6.728000 + + + + -8.220000 + + + + -6.714000 + + + + -7.873000 + + + + -7.380000 + + + + -7.265000 + + + + -7.005000 + + + + -6.951000 + + + + -7.929000 + + + + -8.251000 + + + + -7.399000 + + + + -7.271000 + + + + -7.844000 + + + + -7.669000 + + + + -7.367000 + + + + -8.672000 + + + + -6.968000 + + + + -7.330000 + + + + -7.466000 + + + + -7.242000 + + + + -7.415000 + + + + -7.669000 + + + + -7.385000 + + + + -7.832000 + + + + -5.931000 + + + + -8.276000 + + + + -8.062000 + + + + -8.526000 + + + + -8.432000 + + + + -7.525000 + + + + -8.128000 + + + + -7.987000 + + + + -8.831000 + + + + -7.645000 + + + + -6.964000 + + + + -4.717000 + + + + -6.993000 + + + + -8.121000 + + + + -8.812000 + + + + -8.828000 + + + + -7.891000 + + + + -8.953000 + + + + -9.144000 + + + + -10.221000 + + + + -9.846000 + + + + -9.904000 + + + + -12.265000 + + + + -10.105000 + + + + -10.404000 + + + + -11.420000 + + + + -10.626000 + + + + -10.615000 + + + + -10.999000 + + + + -10.938000 + + + + -11.955000 + + + + -12.620000 + + + + -12.647000 + + + + -13.114000 + + + + -13.360000 + + + + -11.331000 + + + + -11.194000 + + + + -10.316000 + + + + -10.153000 + + + + -9.807000 + + + + -9.494000 + + + + -9.638000 + + + + -10.299000 + + + + -11.139000 + + + + -11.466000 + + + + -11.957000 + + + + -12.044000 + + + + -12.557000 + + + + -11.219000 + + + + -10.748000 + + + + -11.738000 + + + + -12.116000 + + + + -10.817000 + + + + -11.851000 + + + + -11.580000 + + + + -12.076000 + + + + -12.520000 + + + + -13.196000 + + + + -12.414000 + + + + -12.517000 + + + + -11.941000 + + + + -13.258000 + + + + -13.675000 + + + + -13.338000 + + + + -13.715000 + + + + -14.299000 + + + + -13.573000 + + + + -13.615000 + + + + -12.226000 + + + + -12.757000 + + + + -11.726000 + + + + -12.071000 + + + + -13.241000 + + + + -13.098000 + + + + -13.561000 + + + + -13.267000 + + + + -12.906000 + + + + -12.920000 + + + + -12.935000 + + + + -12.764000 + + + + -12.347000 + + + + -15.254000 + + + + -12.123000 + + + + -11.275000 + + + + -12.140000 + + + + -13.102000 + + + + -13.331000 + + + + -12.837000 + + + + -13.077000 + + + + -12.536000 + + + + -12.423000 + + + + -13.082000 + + + + -12.141000 + + + + -12.484000 + + + + -12.963000 + + + + -13.132000 + + + + -13.127000 + + + + -12.979000 + + + + -12.026000 + + + + -13.071000 + + + + -12.805000 + + + + -13.231000 + + + + -13.012000 + + + + -12.666000 + + + + -13.314000 + + + + -13.912000 + + + + -13.431000 + + + + -13.238000 + + + + -13.593000 + + + + -13.523000 + + + + -13.267000 + + + + -12.791000 + + + + -13.328000 + + + + -13.572000 + + + + -13.175000 + + + + -14.032000 + + + + -14.987000 + + + + -11.547000 + + + + -13.235000 + + + + -13.690000 + + + + -13.252000 + + + + -13.832000 + + + + -12.817000 + + + + -13.041000 + + + + -12.779000 + + + + -12.659000 + + + + -12.405000 + + + + -12.114000 + + + + -12.342000 + + + + -12.962000 + + + + -12.657000 + + + + -12.715000 + + + + -12.041000 + + + + -12.876000 + + + + -12.742000 + + + + -14.373000 + + + + -12.702000 + + + + -12.080000 + + + + -12.086000 + + + + -11.968000 + + + + -11.810000 + + + + -12.353000 + + + + -13.172000 + + + + -12.058000 + + + + -16.101000 + + + + -12.192000 + + + + -12.684000 + + + + -12.378000 + + + + -13.012000 + + + + -12.701000 + + + + -10.832000 + + + + -12.397000 + + + + -12.748000 + + + + -12.961000 + + + + -12.928000 + + + + -12.051000 + + + + -13.465000 + + + + -12.719000 + + + + -11.736000 + + + + -12.609000 + + + + -12.248000 + + + + -12.619000 + + + + -12.859000 + + + + -12.190000 + + + + -12.911000 + + + + -13.100000 + + + + -13.310000 + + + + -12.960000 + + + + -12.246000 + + + + -12.240000 + + + + -13.038000 + + + + -12.514000 + + + + -12.347000 + + + + -12.199000 + + + + -12.964000 + + + + -13.078000 + + + + -12.827000 + + + + -12.247000 + + + + -12.791000 + + + + -12.347000 + + + + -12.147000 + + + + -13.438000 + + + + -12.878000 + + + + -12.014000 + + + + -12.020000 + + + + -11.950000 + + + + -11.707000 + + + + -11.601000 + + + + -12.669000 + + + + -11.789000 + + + + -12.269000 + + + + -11.789000 + + + + -11.916000 + + + + -13.658000 + + + + -13.707000 + + + + -13.538000 + + + + -13.309000 + + + + -18.743000 + + + + -10.617000 + + + + -13.168000 + + + + -12.727000 + + + + -13.104000 + + + + -12.341000 + + + + -12.619000 + + + + -12.509000 + + + + -11.970000 + + + + -11.752000 + + + + -11.612000 + + + + -11.871000 + + + + -11.851000 + + + + -12.015000 + + + + -11.360000 + + + + -11.166000 + + + + -10.880000 + + + + -11.213000 + + + + -10.572000 + + + + -10.346000 + + + + -10.056000 + + + + -9.785000 + + + + -10.356000 + + + + -11.008000 + + + + -10.624000 + + + + -10.651000 + + + + -10.277000 + + + + -10.130000 + + + + -10.292000 + + + + -11.029000 + + + + -11.188000 + + + + -10.793000 + + + + -10.014000 + + + + -10.422000 + + + + -10.669000 + + + + -10.596000 + + + + -9.683000 + + + + -9.983000 + + + + -9.584000 + + + + -9.647000 + + + + -9.125000 + + + + -9.426000 + + + + -8.796000 + + + + -8.471000 + + + + -7.991000 + + + + -8.610000 + + + + -8.589000 + + + + -7.818000 + + + + -7.383000 + + + + -7.439000 + + + + -7.870000 + + + + -7.523000 + + + + -7.916000 + + + + -8.037000 + + + + -8.253000 + + + + -8.747000 + + + + -7.948000 + + + + -7.988000 + + + + -8.267000 + + + + -8.664000 + + + + -7.922000 + + + + -7.968000 + + + + -8.933000 + + + + -6.933000 + + + + -7.928000 + + + + -7.842000 + + + + -8.353000 + + + + -8.182000 + + + + -8.020000 + + + + -8.414000 + + + + -8.020000 + + + + -8.409000 + + + + -8.069000 + + + + -7.696000 + + + + -7.436000 + + + + -6.496000 + + + + -8.470000 + + + + -7.362000 + + + + -6.794000 + + + + -6.589000 + + + + -6.320000 + + + + -7.216000 + + + + -6.378000 + + + + -7.175000 + + + + -8.227000 + + + + -7.144000 + + + + -7.057000 + + + + -6.159000 + + + + -6.295000 + + + + -7.022000 + + + + -5.612000 + + + + -7.697000 + + + + -7.248000 + + + + -7.024000 + + + + -7.212000 + + + + -6.072000 + + + + -6.053000 + + + + -5.983000 + + + + -5.952000 + + + + -6.138000 + + + + -6.249000 + + + + -6.448000 + + + + -6.877000 + + + + -6.876000 + + + + -6.502000 + + + + -7.840000 + + + + -6.676000 + + + + -6.908000 + + + + -7.558000 + + + + -6.993000 + + + + -8.263000 + + + + -6.855000 + + + + -5.908000 + + + + -11.790000 + + + + -8.056000 + + + + -6.811000 + + + + -7.799000 + + + + -8.864000 + + + + -8.936000 + + + + -8.724000 + + + + -9.124000 + + + + + ACTIVE LOG185441 + + + -9.124000 + + + + -9.071000 + + + + -8.767000 + + + + -9.595000 + + + + -7.896000 + + + + -8.063000 + + + + -8.273000 + + + + -8.294000 + + + + -7.551000 + + + + -8.195000 + + + + -7.758000 + + + + -6.373000 + + + + -7.383000 + + + + -7.128000 + + + + -7.341000 + + + + -8.194000 + + + + -7.722000 + + + + -8.069000 + + + + -7.073000 + + + + -7.593000 + + + + -7.930000 + + + + -7.563000 + + + + -7.491000 + + + + -7.477000 + + + + -7.413000 + + + + -8.283000 + + + + -7.730000 + + + + -7.945000 + + + + -8.128000 + + + + -7.174000 + + + + -7.968000 + + + + -8.341000 + + + + -7.787000 + + + + -8.342000 + + + + -7.946000 + + + + -12.740000 + + + + -8.317000 + + + + -8.690000 + + + + -8.795000 + + + + -9.354000 + + + + -6.914000 + + + + -6.178000 + + + + -6.643000 + + + + -6.786000 + + + + -6.918000 + + + + + ACTIVE LOG191040 + + + -6.770000 + + + + + ACTIVE LOG191144 + + + -6.553000 + + + + -6.546000 + + + + -6.058000 + + + + + ACTIVE LOG191331 + + + -6.666000 + + + + -5.879000 + + + + -5.799000 + + + + -6.328000 + + + + + ACTIVE LOG191721 + + + -5.773000 + + + + + ACTIVE LOG191747 + + + -5.419000 + + + + + ACTIVE LOG191910 + + + -5.466000 + + + + + ACTIVE LOG191939 + + + -5.361000 + + + + + ACTIVE LOG192018 + + + -5.329000 + + + + + ACTIVE LOG192116 + + + -5.091000 + + + + -4.721000 + + + + -5.215000 + + + + -5.232000 + + + + -5.011000 + + + + -5.080000 + + + + -4.442000 + + + + -8.558000 + + + + -1.408000 + + + + -4.611000 + + + + + ACTIVE LOG192515 + + + -5.213000 + + + + + ACTIVE LOG192847 + + + -4.056000 + + + + -4.162000 + + + + -4.865000 + + + + -3.993000 + + + + -4.795000 + + + + -4.679000 + + + + -4.787000 + + + + -4.772000 + + + + -4.805000 + + + + -4.933000 + + + + -5.028000 + + + + -5.165000 + + + + -5.243000 + + + + -5.022000 + + + + -4.991000 + + + + -4.987000 + + + + -5.181000 + + + + -4.980000 + + + + -4.911000 + + + + -4.869000 + + + + -4.825000 + + + + -4.757000 + + + + -4.851000 + + + + -4.470000 + + + + -4.400000 + + + + -4.564000 + + + + -4.538000 + + + + -4.369000 + + + + -4.499000 + + + + -3.867000 + + + + -3.579000 + + + + -3.127000 + + + + -2.873000 + + + + -3.027000 + + + + -2.617000 + + + + -2.295000 + + + + -1.330000 + + + + -1.151000 + + + + -1.019000 + + + + -0.798000 + + + + -0.701000 + + + + -0.891000 + + + + -1.515000 + + + + -1.504000 + + + + -1.425000 + + + + -0.747000 + + + + -1.574000 + + + + -0.564000 + + + + -6.055000 + + + + -2.019000 + + + + 0.322000 + + + + -0.571000 + + + + -0.761000 + + + + -1.835000 + + + + 0.216000 + + + + + ACTIVE LOG194539 + + + -0.170000 + + + + -3.838000 + + + + -0.773000 + + + + -2.147000 + + + + + ACTIVE LOG194734 + + + -0.249000 + + + + -0.032000 + + + + 0.600000 + + + + -4.598000 + + + + -2.827000 + + + + -2.705000 + + + + -2.724000 + + + + -2.486000 + + + + -3.320000 + + + + -2.516000 + + + + -2.934000 + + + + 0.084000 + + + + -1.524000 + + + + -2.973000 + + + + -3.662000 + + + + -2.902000 + + + + -3.224000 + + + + -3.940000 + + + + -2.512000 + + + + -2.625000 + + + + -3.336000 + + + + -2.798000 + + + + -2.624000 + + + + -2.518000 + + + + -1.991000 + + + + -2.051000 + + + + -2.652000 + + + + -2.363000 + + + + -2.134000 + + + + -2.426000 + + + + -2.353000 + + + + -1.936000 + + + + -2.587000 + + + + -2.265000 + + + + -2.666000 + + + + -2.662000 + + + + -2.972000 + + + + -3.114000 + + + + -3.252000 + + + + -3.147000 + + + + -3.249000 + + + + -3.367000 + + + + -3.661000 + + + + -3.344000 + + + + -3.656000 + + + + -3.274000 + + + + -3.008000 + + + + -3.156000 + + + + -3.730000 + + + + -3.656000 + + + + -3.939000 + + + + -3.885000 + + + + -3.219000 + + + + -3.280000 + + + + -3.399000 + + + + -3.269000 + + + + -2.840000 + + + + -2.966000 + + + + -2.955000 + + + + -3.213000 + + + + -3.166000 + + + + -3.500000 + + + + -3.635000 + + + + -3.154000 + + + + -3.080000 + + + + -2.595000 + + + + -2.737000 + + + + -2.485000 + + + + -2.820000 + + + + -2.608000 + + + + -2.781000 + + + + -2.298000 + + + + -2.860000 + + + + -2.738000 + + + + -3.135000 + + + + -3.172000 + + + + -3.210000 + + + + -3.227000 + + + + -3.129000 + + + + -2.530000 + + + + -2.148000 + + + + -1.977000 + + + + -2.151000 + + + + -1.842000 + + + + -2.067000 + + + + -2.139000 + + + + -2.145000 + + + + -2.680000 + + + + -5.921000 + + + + -2.367000 + + + + -3.013000 + + + + -3.197000 + + + + -2.831000 + + + + -3.083000 + + + + -2.931000 + + + + -2.848000 + + + + -3.631000 + + + + -2.910000 + + + + -2.814000 + + + + -2.876000 + + + + -2.753000 + + + + -3.082000 + + + + -2.910000 + + + + -3.735000 + + + + -3.376000 + + + + -4.003000 + + + + -3.420000 + + + + -3.627000 + + + + -3.471000 + + + + -3.489000 + + + + -3.356000 + + + + -3.158000 + + + + -3.292000 + + + + -4.077000 + + + + -3.611000 + + + + -3.921000 + + + + -3.290000 + + + + -3.839000 + + + + -3.861000 + + + + -3.700000 + + + + -3.568000 + + + + -3.647000 + + + + -4.034000 + + + + -3.767000 + + + + -4.594000 + + + + -4.087000 + + + + -3.950000 + + + + -3.717000 + + + + -3.824000 + + + + -4.494000 + + + + -4.311000 + + + + -3.721000 + + + + -4.295000 + + + + -4.064000 + + + + -4.008000 + + + + -4.437000 + + + + -4.334000 + + + + -4.165000 + + + + -4.634000 + + + + -4.395000 + + + + -4.089000 + + + + -3.970000 + + + + -4.893000 + + + + -5.288000 + + + + -4.750000 + + + + -4.704000 + + + + -4.359000 + + + + -4.526000 + + + + -4.702000 + + + + -4.782000 + + + + -5.147000 + + + + -5.426000 + + + + -5.325000 + + + + -4.981000 + + + + -4.986000 + + + + -5.271000 + + + + -5.270000 + + + + -5.025000 + + + + -5.203000 + + + + -4.982000 + + + + -5.273000 + + + + -5.653000 + + + + -6.188000 + + + + -6.237000 + + + + -6.669000 + + + + -6.587000 + + + + -5.232000 + + + + -6.483000 + + + + -7.262000 + + + + -6.348000 + + + + -8.848000 + + + + -2.956000 + + + + -15.871000 + + + + -3.855000 + + + + -6.571000 + + + + -6.368000 + + + + -6.271000 + + + + -6.543000 + + + + -6.157000 + + + + -6.514000 + + + + -6.504000 + + + + -6.232000 + + + + -5.970000 + + + + -6.014000 + + + + -5.749000 + + + + -6.300000 + + + + -6.157000 + + + + -6.092000 + + + + -6.436000 + + + + -6.182000 + + + + -5.942000 + + + + -5.652000 + + + + -5.836000 + + + + -6.001000 + + + + -6.226000 + + + + -6.167000 + + + + -6.124000 + + + + -6.365000 + + + + -6.103000 + + + + -6.380000 + + + + -6.079000 + + + + -6.571000 + + + + -6.375000 + + + + -6.336000 + + + + -5.727000 + + + + -6.725000 + + + + -6.915000 + + + + -6.815000 + + + + -6.433000 + + + + -6.972000 + + + + -6.996000 + + + + -6.851000 + + + + -7.321000 + + + + -7.202000 + + + + -6.662000 + + + + -6.112000 + + + + -6.057000 + + + + -6.943000 + + + + -7.167000 + + + + -6.750000 + + + + -6.750000 + + + + -7.038000 + + + + -6.892000 + + + + -7.486000 + + + + -7.210000 + + + + -7.725000 + + + + -7.154000 + + + + -7.180000 + + + + -7.642000 + + + + -7.543000 + + + + -7.126000 + + + + -8.115000 + + + + -8.167000 + + + + -7.961000 + + + + -7.618000 + + + + -11.677000 + + + + -9.033000 + + + + -8.561000 + + + + -9.034000 + + + + -8.950000 + + + + -9.199000 + + + + -10.210000 + + + + -9.760000 + + + + -9.967000 + + + + -10.115000 + + + + -10.042000 + + + + -9.880000 + + + + -9.696000 + + + + -9.924000 + + + + -9.786000 + + + + -9.618000 + + + + -9.160000 + + + + -9.369000 + + + + -9.359000 + + + + -9.399000 + + + + -7.994000 + + + + -8.416000 + + + + -8.487000 + + + + -8.582000 + + + + -8.728000 + + + + -8.147000 + + + + -8.304000 + + + + -7.939000 + + + + -8.047000 + + + + -8.051000 + + + + -8.001000 + + + + -8.187000 + + + + -8.352000 + + + + -8.145000 + + + + -8.508000 + + + + -8.525000 + + + + -8.145000 + + + + -7.578000 + + + + -8.375000 + + + + -8.390000 + + + + -7.703000 + + + + -8.050000 + + + + -8.512000 + + + + -8.468000 + + + + -8.664000 + + + + -11.858000 + + + + -7.441000 + + + + -7.870000 + + + + -8.145000 + + + + -7.546000 + + + + -7.874000 + + + + -8.007000 + + + + -7.586000 + + + + -8.127000 + + + + -8.550000 + + + + -8.139000 + + + + -8.284000 + + + + -8.988000 + + + + -8.461000 + + + + -8.965000 + + + + -8.187000 + + + + -9.142000 + + + + -8.945000 + + + + -9.180000 + + + + -9.270000 + + + + -9.167000 + + + + -9.257000 + + + + -9.338000 + + + + -9.776000 + + + + -9.747000 + + + + -9.792000 + + + + -9.879000 + + + + -9.871000 + + + + -10.006000 + + + + -10.288000 + + + + -10.304000 + + + + -10.035000 + + + + -10.155000 + + + + -9.858000 + + + + -9.573000 + + + + -10.155000 + + + + -9.946000 + + + + -9.981000 + + + + -10.462000 + + + + -10.254000 + + + + -10.492000 + + + + -10.238000 + + + + -10.425000 + + + + -10.966000 + + + + -10.071000 + + + + -9.936000 + + + + -9.972000 + + + + -10.103000 + + + + -10.300000 + + + + -10.467000 + + + + -10.855000 + + + + -10.167000 + + + + -10.373000 + + + + -10.184000 + + + + -10.767000 + + + + -10.431000 + + + + -10.515000 + + + + -10.942000 + + + + -10.754000 + + + + -11.498000 + + + + -10.758000 + + + + -11.066000 + + + + -11.164000 + + + + -11.230000 + + + + -11.294000 + + + + -11.217000 + + + + -11.331000 + + + + -11.153000 + + + + -11.730000 + + + + -10.778000 + + + + -12.492000 + + + + -10.680000 + + + + -12.426000 + + + + -11.938000 + + + + -12.267000 + + + + -12.176000 + + + + -12.191000 + + + + -12.565000 + + + + -12.457000 + + + + -12.138000 + + + + -11.837000 + + + + -11.972000 + + + + -11.706000 + + + + -12.507000 + + + + -12.110000 + + + + -12.224000 + + + + -13.297000 + + + + -13.106000 + + + + -13.183000 + + + + -12.920000 + + + + -12.844000 + + + + -13.053000 + + + + -13.202000 + + + + -12.726000 + + + + -13.598000 + + + + -13.463000 + + + + -13.831000 + + + + -13.663000 + + + + -13.513000 + + + + -13.820000 + + + + -13.760000 + + + + -13.575000 + + + + -13.327000 + + + + -13.553000 + + + + -13.660000 + + + + -13.332000 + + + + -13.481000 + + + + -13.340000 + + + + -13.083000 + + + + -12.435000 + + + + -13.156000 + + + + -13.072000 + + + + -13.103000 + + + + -12.406000 + + + + -14.975000 + + + + -14.132000 + + + + -15.527000 + + + + -14.594000 + + + + -14.297000 + + + + -13.854000 + + + + diff --git a/Assets/Scripts/KerstSpecial/20120210 Elfstedentocht.txt.meta b/Assets/Scripts/KerstSpecial/20120210 Elfstedentocht.txt.meta new file mode 100644 index 000000000..fe55ac8df --- /dev/null +++ b/Assets/Scripts/KerstSpecial/20120210 Elfstedentocht.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3653738e64b9fdb44a2b7a94ac1bfed4 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/KerstSpecial/RaceController.cs b/Assets/Scripts/KerstSpecial/RaceController.cs index eff5382bd..860c258b1 100644 --- a/Assets/Scripts/KerstSpecial/RaceController.cs +++ b/Assets/Scripts/KerstSpecial/RaceController.cs @@ -5,6 +5,7 @@ using Netherlands3D.Twin.Projects; using System.Collections; using System.Collections.Generic; +using System.Xml; using UnityEngine; using UnityEngine.InputSystem; @@ -23,11 +24,13 @@ public class RaceController : MonoBehaviour private float rotationSpeed = 60f; private float playerSpeed = 10f; private float slipFactor = 0.99f; + public float jumpForce = 10; private Vector3 unityStartTarget; private Vector3 playerMoveVector = Vector3.zero; private Quaternion cameraStartRotation; private bool isReadyForStart = false; + private bool isReadyToMove = false; private Layer maaiveld; private Layer gebouwen; @@ -38,15 +41,15 @@ public class RaceController : MonoBehaviour [SerializeField] private FloatEvent horizontalInput; [SerializeField] private FloatEvent verticalInput; [SerializeField] private FloatEvent upDownInput; + [SerializeField] private BoolEvent jumpInput; + + [SerializeField] private TextAsset routeFile; + private List routeCoords = new List(); //53.198472, 5.791865 private Coordinate coord = new Coordinate(CoordinateSystem.WGS84, 53.198472d, 5.791865d, 0); - private void Awake() - { - - } - + private void Start() { freeCam = FindObjectOfType(); @@ -55,24 +58,49 @@ private void Start() horizontalInput.AddListenerStarted(MoveHorizontally); verticalInput.AddListenerStarted(MoveForwardBackwards); upDownInput.AddListenerStarted(MoveUpDown); + jumpInput.AddListenerStarted(Jump); + + GetCoordinatesForRoute(); + InitPlayer(); + } - player = GameObject.CreatePrimitive(PrimitiveType.Capsule); + private void InitPlayer() + { + player = GameObject.CreatePrimitive(PrimitiveType.Capsule); playerRigidBody = player.AddComponent(); + WorldTransform wt = player.AddComponent(); + GameObjectWorldTransformShifter shifter = player.AddComponent(); + wt.SetShifter(shifter); playerRigidBody.useGravity = false; playerRigidBody.collisionDetectionMode = CollisionDetectionMode.Continuous; playerRigidBody.angularDrag = 0; playerRigidBody.angularVelocity = Vector3.zero; + playerRigidBody.mass = 100; + Physics.gravity = Vector3.down * 30; + + } - WorldTransform wt = player.AddComponent(); - GameObjectWorldTransformShifter shifter = player.AddComponent(); - wt.SetShifter(shifter); - GetLayers(); + private bool hasJumped = false; + private float jumpTimer = 0; + private float jumpInterval = 1f; + private void Jump(bool jump) + { + if(!hasJumped && jump && isReadyToMove && jumpTimer < 0) + { + playerRigidBody.AddForce(Vector3.up * playerRigidBody.mass * jumpForce, ForceMode.Impulse); + hasJumped = true; + jumpTimer = jumpInterval; + } } private void FixedUpdate() { + if (!isReadyToMove) + return; + //playerRigidBody.AddForce(player.transform.rotation * playerMoveVector * Time.fixedDeltaTime); - playerRigidBody.velocity = player.transform.rotation * playerMoveVector * Time.fixedDeltaTime; + Vector3 vec = player.transform.rotation * playerMoveVector * Time.fixedDeltaTime; + playerRigidBody.velocity = new Vector3(vec.x, playerRigidBody.velocity.y, vec.z); if (raycaster == null) { raycaster = FindObjectOfType(); @@ -81,15 +109,27 @@ private void FixedUpdate() { Vector2 screenPoint = Camera.main.WorldToScreenPoint(player.transform.position + Vector3.down); //bottom of player Vector3 floorPoint = raycaster.GetWorldPointAtCameraScreenPoint(Camera.main, new Vector3(screenPoint.x, screenPoint.y, 0)); - //float yDist = Mathf.Abs(floorPoint.y - player.transform.position.y); - floorPoint.y = -1; //ugly fix but bettter for now - playerRigidBody.transform.SetPositionAndRotation(Vector3.Slerp(player.transform.position, new Vector3(player.transform.position.x, floorPoint.y, player.transform.position.z), Time.fixedDeltaTime * 3), player.transform.rotation); + float yDist = Mathf.Abs(floorPoint.y - player.transform.position.y); + floorPoint.y = -1; //ugly fix but better for now + bool isGrounded = yDist < 1f; + Debug.Log("isgrounded:" + isGrounded); + if(isGrounded) + { + hasJumped = false; + } + + if (playerRigidBody.position.y < floorPoint.y) + { + playerRigidBody.transform.SetPositionAndRotation(new Vector3(playerRigidBody.position.x, floorPoint.y, playerRigidBody.position.z), player.transform.rotation); + } + //playerRigidBody.transform.SetPositionAndRotation(Vector3.Lerp(player.transform.position, new Vector3(player.transform.position.x, floorPoint.y, player.transform.position.z), Time.fixedDeltaTime * 3), player.transform.rotation); playerRigidBody.angularVelocity = Vector3.zero; } } private void Update() { + jumpTimer -= Time.deltaTime; unityStartTarget = coord.ToUnity(); unityStartTarget.y = camHeight; if ((Vector3.Distance(freeCam.transform.position, unityStartTarget) > 1 || Quaternion.Angle(freeCam.transform.rotation, cameraStartRotation) > 1) && !isReadyForStart) @@ -98,11 +138,9 @@ private void Update() freeCam.transform.rotation = Quaternion.Slerp(freeCam.transform.rotation, cameraStartRotation, Time.deltaTime * camLerpSpeed); } else - { - if (!isReadyForStart) - { - player.transform.position = freeCam.transform.position + freeCam.transform.forward * playerDistToCamera; - } + { + if(!isReadyForStart) + player.transform.position = freeCam.transform.position + freeCam.transform.forward * playerDistToCamera; isReadyForStart = true; } @@ -127,11 +165,10 @@ private void Update() playerMoveVector *= slipFactor; if (playerMoveVector.magnitude <= 0.02f) - playerMoveVector = Vector3.zero; + playerMoveVector = Vector3.zero; - - - GetClosestTileAndUpdateCollider(player.transform.position, out bool isGrounded); + GetClosestTileAndUpdateCollider(player.transform.position, out bool isGrounded); + isReadyToMove = isGrounded; playerRigidBody.useGravity = isGrounded; } @@ -179,6 +216,11 @@ public void GetClosestTileAndUpdateCollider(Vector3 position, out bool isGrounde Vector2Int tileKey = GetTileKeyFromUnityPosition(position, 1000); string tileName = tileKey.x.ToString() + "-" + tileKey.y.ToString(); isGrounded = false; + if(maaiveld == null || gebouwen == null) + { + GetLayers(); + } + if (maaiveld != null) { foreach (Transform t in maaiveld.transform.GetComponentInChildren()) @@ -227,5 +269,54 @@ public Vector2Int GetTileKeyFromUnityPosition(Vector3 position, int tileSize) Vector2Int key = new Vector2Int(Mathf.RoundToInt(((float)coord.Points[0] - 0.5f * tileSize) / 1000) * 1000, Mathf.RoundToInt(((float)coord.Points[1] - 0.5f * tileSize) / 1000) * 1000); return key; } + + private void GetCoordinatesForRoute() + { + if (routeFile != null) + { + routeCoords = ExtractLatLon(routeFile.text); + + foreach(Vector2 c in routeCoords) + { + Coordinate coord = new Coordinate(CoordinateSystem.WGS84, c.x, c.y, 0); + GameObject routeObject = GameObject.CreatePrimitive(PrimitiveType.Cube); + routeObject.transform.localScale = Vector3.one * 5f; + WorldTransform wt = routeObject.AddComponent(); + GameObjectWorldTransformShifter shifter = routeObject.AddComponent(); + wt.SetShifter(shifter); + Vector3 unityCoord = coord.ToUnity(); + unityCoord.y = 2; + routeObject.transform.position = unityCoord; + } + } + else + { + Debug.LogError("GPX file not assigned."); + } + } + + List ExtractLatLon(string gpxContent) + { + List latLonList = new List(); + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(gpxContent); + + XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable); + nsmgr.AddNamespace("gpx", "http://www.topografix.com/GPX/1/1"); + + XmlNodeList trkptNodes = xmlDoc.SelectNodes("//gpx:trkpt", nsmgr); + + foreach (XmlNode trkpt in trkptNodes) + { + if (trkpt.Attributes["lat"] != null && trkpt.Attributes["lon"] != null) + { + float lat = float.Parse(trkpt.Attributes["lat"].Value); + float lon = float.Parse(trkpt.Attributes["lon"].Value); + latLonList.Add(new Vector2(lat, lon)); + } + } + + return latLonList; + } } }