Skip to content

Commit

Permalink
some fixes for controlls and coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
bozmir committed Dec 17, 2024
1 parent ddaccdd commit d66c583
Show file tree
Hide file tree
Showing 8 changed files with 5,568 additions and 28 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -448,6 +457,17 @@
"action": "Fly",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "eb3034d1-6238-4c5e-8254-e9769086a0a2",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.UI;
using Netherlands3D.Events;
#endif

/* Copyright(C) X Gemeente
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Vector2>();
var draggingSecondary = !lockDraggingInput && secondaryPointerPosition.magnitude > 0;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 12 additions & 4 deletions Assets/Scenes/Main.unity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d66c583

Please sign in to comment.