Skip to content

Commit 9120cf4

Browse files
committed
Tweaking the thresholds for actions
1 parent d591e23 commit 9120cf4

File tree

3 files changed

+52
-45
lines changed

3 files changed

+52
-45
lines changed

Assets/HoloToolkit/Input/Prefabs/TeleportMarker.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Transform:
116116
m_GameObject: {fileID: 1503526479864244}
117117
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
118118
m_LocalPosition: {x: 0, y: 0, z: 0}
119-
m_LocalScale: {x: 1.5, y: 1.5, z: 1.5}
119+
m_LocalScale: {x: 5, y: 5, z: 5}
120120
m_Children:
121121
- {fileID: 4016362903904820}
122122
- {fileID: 4557482788704076}

Assets/HoloToolkit/Input/Scripts/Focus/InputSourcePointer.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ namespace HoloToolkit.Unity.InputModule
1111
/// Class implementing IPointingSource to demonstrate how to create a pointing source.
1212
/// This is consumed by SimpleSinglePointerSelector.
1313
/// </summary>
14-
public class InputSourcePointer :
15-
IPointingSource
14+
public class InputSourcePointer : IPointingSource
1615
{
1716
public IInputSource InputSource { get; set; }
1817

@@ -69,8 +68,7 @@ public bool InputIsFromSource(BaseEventData eventData)
6968

7069
return (inputData != null)
7170
&& (inputData.InputSource == InputSource)
72-
&& (inputData.SourceId == InputSourceId)
73-
;
71+
&& (inputData.SourceId == InputSourceId);
7472
}
7573
}
7674
}

Assets/HoloToolkit/Input/Scripts/Gaze/MixedRealityTeleport.cs

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ namespace HoloToolkit.Unity.InputModule
1414
[RequireComponent(typeof(SetGlobalListener))]
1515
public class MixedRealityTeleport : Singleton<MixedRealityTeleport>, IControllerInputHandler
1616
{
17-
[Tooltip("Name of the joystick axis to move along X.")]
18-
public string LeftJoystickX = "ControllerLeftStickX";
17+
[Tooltip("Name of the thumbstick axis to check for teleport and strafe.")]
18+
public string LeftThumbstickX = "ControllerLeftStickX";
1919

20-
[Tooltip("Name of the joystick axis to move along Y.")]
21-
public string LeftJoystickY = "ControllerLeftStickY";
20+
[Tooltip("Name of the thumbstick axis to check for teleport and strafe.")]
21+
public string LeftThumbstickY = "ControllerLeftStickY";
22+
23+
[Tooltip("Name of the thumbstick axis to check for rotation.")]
24+
public string RightThumbstickX = "ControllerRightStickX";
25+
26+
[Tooltip("Name of the thumbstick axis to check for rotation.")]
27+
public string RightThumbstickY = "ControllerRightStickY";
2228

2329
public bool EnableTeleport = true;
2430
public bool EnableRotation = true;
@@ -78,51 +84,51 @@ private void HandleGamepad()
7884
{
7985
if (EnableTeleport && !fadeControl.Busy)
8086
{
81-
float leftX = Input.GetAxis("ControllerLeftStickX");
82-
float leftY = Input.GetAxis("ControllerLeftStickY");
87+
float leftX = Input.GetAxis(LeftThumbstickX);
88+
float leftY = Input.GetAxis(LeftThumbstickY);
8389

84-
if (currentPointingSource == null && leftY > 0.8 && Math.Abs(leftX) < 0.2)
90+
if (currentPointingSource == null && leftY > 0.8 && Math.Abs(leftX) < 0.3)
8591
{
8692
if (FocusManager.Instance.TryGetSinglePointer(out currentPointingSource))
8793
{
8894
StartTeleport();
8995
}
9096
}
91-
else if (currentPointingSource != null && Math.Sqrt(Math.Pow(leftX, 2) + Math.Pow(leftY, 2)) < 0.1)
97+
else if (currentPointingSource != null && new Vector2(leftX, leftY).magnitude < 0.2)
9298
{
9399
FinishTeleport();
94100
}
95101
}
96102

97103
if (EnableStrafe && currentPointingSource == null && !fadeControl.Busy)
98104
{
99-
float leftX = Input.GetAxis("ControllerLeftStickX");
100-
float leftY = Input.GetAxis("ControllerLeftStickY");
105+
float leftX = Input.GetAxis(LeftThumbstickX);
106+
float leftY = Input.GetAxis(LeftThumbstickY);
101107

102-
if (leftX < -0.8 && Math.Abs(leftY) < 0.2)
108+
if (leftX < -0.8 && Math.Abs(leftY) < 0.3)
103109
{
104110
DoStrafe(Vector3.left * StrafeAmount);
105111
}
106-
else if (leftX > 0.8 && Math.Abs(leftY) < 0.2)
112+
else if (leftX > 0.8 && Math.Abs(leftY) < 0.3)
107113
{
108114
DoStrafe(Vector3.right * StrafeAmount);
109115
}
110-
else if (leftY < -0.8 && Math.Abs(leftX) < 0.2)
116+
else if (leftY < -0.8 && Math.Abs(leftX) < 0.3)
111117
{
112118
DoStrafe(Vector3.back * StrafeAmount);
113119
}
114120
}
115121

116122
if (EnableRotation && currentPointingSource == null && !fadeControl.Busy)
117123
{
118-
float rightX = Input.GetAxis("ControllerRightStickX");
119-
float rightY = Input.GetAxis("ControllerRightStickY");
124+
float rightX = Input.GetAxis(RightThumbstickX);
125+
float rightY = Input.GetAxis(RightThumbstickY);
120126

121-
if (rightX < -0.8 && Math.Abs(rightY) < 0.2)
127+
if (rightX < -0.8 && Math.Abs(rightY) < 0.3)
122128
{
123129
DoRotation(-RotationSize);
124130
}
125-
else if (rightX > 0.8 && Math.Abs(rightY) < 0.2)
131+
else if (rightX > 0.8 && Math.Abs(rightY) < 0.3)
126132
{
127133
DoRotation(RotationSize);
128134
}
@@ -131,39 +137,42 @@ private void HandleGamepad()
131137

132138
void IControllerInputHandler.OnInputPositionChanged(InputPositionEventData eventData)
133139
{
134-
if (EnableTeleport)
140+
if (eventData.PressType == InteractionSourcePressType.Thumbstick)
135141
{
136-
if (currentPointingSource == null && eventData.Position.y > 0.8 && Math.Abs(eventData.Position.x) < 0.2)
142+
if (EnableTeleport)
137143
{
138-
if (FocusManager.Instance.TryGetPointingSource(eventData, out currentPointingSource))
144+
if (currentPointingSource == null && eventData.Position.y > 0.8 && Math.Abs(eventData.Position.x) < 0.3)
139145
{
140-
currentSourceId = eventData.SourceId;
141-
StartTeleport();
146+
if (FocusManager.Instance.TryGetPointingSource(eventData, out currentPointingSource))
147+
{
148+
currentSourceId = eventData.SourceId;
149+
StartTeleport();
150+
}
151+
}
152+
else if (currentPointingSource != null && currentSourceId == eventData.SourceId && eventData.Position.magnitude < 0.2)
153+
{
154+
FinishTeleport();
142155
}
143156
}
144-
else if (currentPointingSource != null && currentSourceId == eventData.SourceId && eventData.Position.magnitude < 0.1)
145-
{
146-
FinishTeleport();
147-
}
148-
}
149157

150-
if (EnableStrafe && currentPointingSource == null)
151-
{
152-
if (eventData.Position.y < -0.8 && Math.Abs(eventData.Position.x) < 0.2)
158+
if (EnableStrafe && currentPointingSource == null)
153159
{
154-
DoStrafe(Vector3.back * StrafeAmount);
160+
if (eventData.Position.y < -0.8 && Math.Abs(eventData.Position.x) < 0.3)
161+
{
162+
DoStrafe(Vector3.back * StrafeAmount);
163+
}
155164
}
156-
}
157165

158-
if (EnableRotation && currentPointingSource == null)
159-
{
160-
if (eventData.Position.x < -0.8 && Math.Abs(eventData.Position.y) < 0.2)
161-
{
162-
DoRotation(-RotationSize);
163-
}
164-
else if (eventData.Position.x > 0.8 && Math.Abs(eventData.Position.y) < 0.2)
166+
if (EnableRotation && currentPointingSource == null)
165167
{
166-
DoRotation(RotationSize);
168+
if (eventData.Position.x < -0.8 && Math.Abs(eventData.Position.y) < 0.3)
169+
{
170+
DoRotation(-RotationSize);
171+
}
172+
else if (eventData.Position.x > 0.8 && Math.Abs(eventData.Position.y) < 0.3)
173+
{
174+
DoRotation(RotationSize);
175+
}
167176
}
168177
}
169178
}

0 commit comments

Comments
 (0)