Skip to content

Commit

Permalink
fix(Locomotion): correctly set other touchpad control enable state
Browse files Browse the repository at this point in the history
There was an issue where if the touchpad was being held down when the
scene started and then released, the other touchpad control enable
state was being set to disabled because the touchpad axis change
hadn't occurred therefore the previous object control state was
always being set to false.
  • Loading branch information
thestonefox committed Oct 3, 2017
1 parent af355fd commit 3812bf6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Assets/VRTK/Source/Scripts/Locomotion/VRTK_TouchpadControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ public class VRTK_TouchpadControl : VRTK_ObjectControl

protected bool touchpadFirstChange;
protected bool otherTouchpadControlEnabledState;
protected bool otherTouchpadControlEnabledStateSet;

protected override void OnEnable()
{
base.OnEnable();
touchpadFirstChange = true;
otherTouchpadControlEnabledStateSet = false;
}

protected override void ControlFixedUpdate()
Expand Down Expand Up @@ -112,9 +114,10 @@ protected virtual bool TouchpadTouched()

protected virtual void TouchpadAxisChanged(object sender, ControllerInteractionEventArgs e)
{
if (touchpadFirstChange && otherObjectControl && disableOtherControlsOnActive && e.touchpadAxis != Vector2.zero)
if (touchpadFirstChange && otherObjectControl != null && disableOtherControlsOnActive && e.touchpadAxis != Vector2.zero)
{
otherTouchpadControlEnabledState = otherObjectControl.enabled;
otherTouchpadControlEnabledStateSet = true;
otherObjectControl.enabled = false;
}
currentAxis = (ValidPrimaryButton() ? e.touchpadAxis : Vector2.zero);
Expand All @@ -127,7 +130,7 @@ protected virtual void TouchpadAxisChanged(object sender, ControllerInteractionE

protected virtual void TouchpadTouchEnd(object sender, ControllerInteractionEventArgs e)
{
if (otherObjectControl && disableOtherControlsOnActive)
if (otherTouchpadControlEnabledStateSet && otherObjectControl != null && disableOtherControlsOnActive)
{
otherObjectControl.enabled = otherTouchpadControlEnabledState;
}
Expand Down

0 comments on commit 3812bf6

Please sign in to comment.