Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,4 @@
]
}
]
}
}
3 changes: 2 additions & 1 deletion Basis/Basis.slnx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Solution>
<Solution>
<Project Path="Unity.Timeline.csproj" />
<Project Path="Unity.VisualEffectGraph.Editor.csproj" />
<Project Path="Unity.RenderPipelines.GPUDriven.Runtime.csproj" />
Expand Down Expand Up @@ -60,6 +60,7 @@
<Project Path="Unity.TextMeshPro.Editor.csproj" />
<Project Path="SteamVR_Input_Editor.csproj" />
<Project Path="Unity.Services.Analytics.Editor.csproj" />
<Project Path="BasisVehicles.csproj" />
<Project Path="Unity.Burst.Editor.csproj" />
<Project Path="Meta.XR.Editor.Tags.csproj" />
<Project Path="BasisSDK.csproj" />
Expand Down
10 changes: 10 additions & 0 deletions Basis/Packages/com.basis.common/BasisLocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ public bool Contains(string key)
return lockList.Contains(key);
}

public bool ContainsOnly(string key)
{
int count = Count;
if (count == 0) return false;
if (count > 1) return false;
if (!Locks.TryGetValue(Context, out var lockList)) return false;
lock (ListLocks[Context])
return lockList[0] == key;
}

public void CopyTo(string[] array, int arrayIndex)
{
ToArray().CopyTo(array, arrayIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public void HandleLookRotation(Vector2 lookVector)
rotationYaw += lookVector.x * rotationSpeed; // yaw
rotationPitch -= lookVector.y * rotationSpeed; // pitch (invert Y)
}

/// <summary>
/// Main polling loop for updating eye input state.
/// Calculates eye position/rotation based on avatar head, crouching, and inputs deltas.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,13 @@ public void Sit(BasisSeat seat)
LocalPlayer.LocalAnimatorDriver.PauseAnimator = true;
if (BasisDesktopEye.Instance != null)
{
// Set the player's relative yaw to zero to face forward on the seat, but don't do the same for pitch.
// Set the player's relative yaw to zero to face forward on the seat.
BasisDesktopEye.Instance.rotationYaw = 0.0f;
// Only do the same for pitch if requested by the seat, to avoid disorienting the player.
if (_seat.ResetPitchOnEntry)
{
BasisDesktopEye.Instance.rotationPitch = 0.0f;
}
}
_setAllOverrideUsages(true);
LocalPlayer.OnPreSimulateBones += OnSimulate;
Expand All @@ -143,7 +148,7 @@ public void Stand()
}

LocalPlayer.LocalAnimatorDriver.PauseAnimator = false;
_seat.OnExitSeat();
_seat.OnExitSeat(LocalPlayer);
BasisLocalVirtualSpineDriver.HipsFreezeToTpose = false;
LocalPlayer.OnPreSimulateBones -= OnSimulate;
LocalPlayer.LocalCharacterDriver.MovementLock.Remove(nameof(BasisLocalSeatDriver));
Expand Down
33 changes: 15 additions & 18 deletions Basis/Packages/com.basis.framework/Interactions/BasisSeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,12 @@ public override void OnDestroy()
#endregion Unity Lifecycle Hooks

#region Basis Integration
public Action<BasisPlayer> OnPlayerEnterSeat;
public Action<BasisPlayer> OnPlayerExitSeat;
private BasisInput _interactingInput = null;
public bool IsSeatTakenByAnyone = false;
private bool IsSeatTakenByAnyone = false;
public bool LocallyInSeat;
public bool ResetPitchOnEntry = false;
public override bool CanHover(BasisInput input)
{
// Can only hover when not already hovering or interacting.
Expand Down Expand Up @@ -516,24 +519,10 @@ public override void OnInteractStart(BasisInput input)
else
{
BasisLocalPlayer.Instance.LocalSeatDriver.Sit(this);
SetSeatOccupied(true);
LocallyInSeat = true;
OnEnterSeat(BasisLocalPlayer.Instance);
}
base.OnInteractStart(input);
}
public void Sit()
{
BasisLocalPlayer.Instance.LocalSeatDriver.Sit(this);
SetSeatOccupied(true);
LocallyInSeat = true;
}
public void Stand()
{
BasisLocalPlayer.Instance.LocalSeatDriver.Stand();
SetSeatOccupied(false);
LocallyInSeat = false;
}


public override void OnInteractEnd(BasisInput input)
{
Expand All @@ -544,17 +533,25 @@ public override void OnInteractEnd(BasisInput input)
Inputs.ChangeStateByRole(wrapper.Role, BasisInteractInputState.Ignored);
_interactingInput = null;
}

}
}

public void OnEnterSeat(BasisPlayer player)
{
SetSeatOccupied(true);
LocallyInSeat = true;
OnPlayerEnterSeat?.Invoke(player);
}

/// <summary>
/// this one actually does the callback.
/// </summary>
public void OnExitSeat()
public void OnExitSeat(BasisPlayer player)
{
base.OnInteractEnd(null);
SetSeatOccupied(false);
LocallyInSeat = false;
OnPlayerExitSeat?.Invoke(player);
}
#endregion Basis Integration
}
Expand Down
20 changes: 20 additions & 0 deletions Basis/Packages/com.basis.vehicles/basis_vehicles.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "BasisVehicles",
"rootNamespace": "",
"references": [
"BasisCommon",
"BasisDebug",
"BasisSDK",
"Basis Framework",
"Unity.InputSystem"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Basis/Packages/com.basis.vehicles/basis_vehicles.asmdef.meta

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

8 changes: 8 additions & 0 deletions Basis/Packages/com.basis.vehicles/examples.meta

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

Loading
Loading