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
29 changes: 27 additions & 2 deletions Assets/Gothic-VR/Resources/VR/Prefabs/VR - Player XRI.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ GameObject:
- component: {fileID: 6560536017312742706}
- component: {fileID: 5987075695519224435}
- component: {fileID: 5504711397442723850}
- component: {fileID: 3506189809021101468}
m_Layer: 8
m_Name: Locomotion
m_TagString: Untagged
Expand Down Expand Up @@ -832,6 +833,29 @@ MonoBehaviour:
m_ManualQueueWasCompletedThisFrame: 0
m_ManualQueueValue: 0
m_ManualQueueTargetFrame: 0
--- !u!114 &3506189809021101468
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3580888346999583535}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 496880615cd240be960d436c1c8ae570, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.XR.Interaction.Toolkit::UnityEngine.XR.Interaction.Toolkit.Locomotion.Climbing.ClimbProvider
m_Mediator: {fileID: 0}
m_TransformationPriority: 0
m_ProvidersToDisable: []
m_EnableGravityOnClimbEnd: 1
m_ClimbSettings:
m_UseConstant: 1
m_ConstantValue:
m_AllowFreeXMovement: 1
m_AllowFreeYMovement: 1
m_AllowFreeZMovement: 1
m_Variable: {fileID: 0}
--- !u!1 &3942069294043007131
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3620,6 +3644,7 @@ MonoBehaviour:
_teleportationProvider: {fileID: 5987075695519224435}
_gravityProvider: {fileID: 1435405315088257603}
_jumpProvider: {fileID: 5504711397442723850}
_climbProvider: {fileID: 3506189809021101468}
_teleportAimer: {fileID: 8981795712984714}
_moveSpeed: 1.5
_runSpeed: 3.5
Expand Down Expand Up @@ -5141,11 +5166,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 6272730690859954775, guid: 8348fe5825a421c42be0dad392e03669, type: 3}
propertyPath: m_Size
value: 0.9514286
value: 0.95142865
objectReference: {fileID: 0}
- target: {fileID: 6272730690859954775, guid: 8348fe5825a421c42be0dad392e03669, type: 3}
propertyPath: m_Value
value: 10.795005
value: 1.0000467
objectReference: {fileID: 0}
- target: {fileID: 8278234239060405203, guid: 8348fe5825a421c42be0dad392e03669, type: 3}
propertyPath: m_AnchorMax.x
Expand Down
147 changes: 147 additions & 0 deletions Assets/Gothic-VR/Resources/VR/Prefabs/Vobs/oCMobLadder.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ GameObject:
- component: {fileID: 2893514479669655516}
- component: {fileID: 5158607502795523759}
- component: {fileID: 1622434811052915792}
- component: {fileID: 7187644040872247837}
- component: {fileID: 2541870062922728126}
- component: {fileID: 5419451996241642929}
- component: {fileID: 2186640121397330077}
m_Layer: 0
m_Name: BIP01 LADDER
m_TagString: Untagged
Expand Down Expand Up @@ -212,6 +216,149 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 594f5e7857d0629419c1bef807639a86, type: 3}
m_Name:
m_EditorClassIdentifier: Gothic.VR::Gothic.VR.Interaction.Backends.Hvr.HvrInteractableBridge
--- !u!54 &7187644040872247837
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3766033816963121094}
serializedVersion: 5
m_Mass: 1
m_LinearDamping: 0
m_AngularDamping: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &2541870062922728126
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3766033816963121094}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e9e72fe1e3b49f8a1fee8aa4ed33fe8, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.XR.Interaction.Toolkit::UnityEngine.XR.Interaction.Toolkit.Locomotion.Climbing.ClimbInteractable
m_InteractionManager: {fileID: 0}
m_Colliders: []
m_InteractionLayers:
m_Bits: 1
m_DistanceCalculationMode: 1
m_SelectMode: 1
m_FocusMode: 1
m_CustomReticle: {fileID: 0}
m_AllowGazeInteraction: 0
m_AllowGazeSelect: 0
m_OverrideGazeTimeToSelect: 0
m_GazeTimeToSelect: 0.5
m_OverrideTimeToAutoDeselectGaze: 0
m_TimeToAutoDeselectGaze: 3
m_AllowGazeAssistance: 0
m_FirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_LastHoverExited:
m_PersistentCalls:
m_Calls: []
m_HoverEntered:
m_PersistentCalls:
m_Calls: []
m_HoverExited:
m_PersistentCalls:
m_Calls: []
m_FirstSelectEntered:
m_PersistentCalls:
m_Calls: []
m_LastSelectExited:
m_PersistentCalls:
m_Calls: []
m_SelectEntered:
m_PersistentCalls:
m_Calls: []
m_SelectExited:
m_PersistentCalls:
m_Calls: []
m_FirstFocusEntered:
m_PersistentCalls:
m_Calls: []
m_LastFocusExited:
m_PersistentCalls:
m_Calls: []
m_FocusEntered:
m_PersistentCalls:
m_Calls: []
m_FocusExited:
m_PersistentCalls:
m_Calls: []
m_Activated:
m_PersistentCalls:
m_Calls: []
m_Deactivated:
m_PersistentCalls:
m_Calls: []
m_StartingHoverFilters: []
m_StartingSelectFilters: []
m_StartingInteractionStrengthFilters: []
m_AutoFindParentInteractableInHierarchy: 0
m_ParentInteractableObject: {fileID: 0}
m_ClimbProvider: {fileID: 0}
m_ClimbTransform: {fileID: 5485219827508946200}
m_FilterInteractionByDistance: 1
m_MaxInteractionDistance: 0.15
m_ClimbAssistanceTeleportVolume: {fileID: 0}
m_ClimbSettingsOverride:
m_UseConstant: 0
m_ConstantValue:
m_AllowFreeXMovement: 1
m_AllowFreeYMovement: 1
m_AllowFreeZMovement: 1
m_Variable: {fileID: 0}
--- !u!114 &5419451996241642929
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3766033816963121094}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d53defac19fbb474d81910e60e275fd7, type: 3}
m_Name:
m_EditorClassIdentifier: Gothic.VR::Gothic.VR.Interaction.Backends.Xri.XriInteractableBridge
--- !u!114 &2186640121397330077
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3766033816963121094}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7b9a70dafc6612a4ca4de9e05baa221e, type: 3}
m_Name:
m_EditorClassIdentifier: Gothic.VR::Gothic.VR.Interaction.Components.VrLadderExit
_headAboveTop: 0.15
_exitDistances:
- 0.5
- 0.8
_floorTolerance: 0.5
_retryInterval: 0.5
--- !u!1 &6503575194566409312
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ namespace Gothic.VR.Interaction.Backends.Xri
/// per hand, GothicGrabInteractable + XriInteractableBridge on oCItem), using mobs/NPCs and the socket core
/// (VrSocketSlot + XriSocketBridge, "VR Socket Slot.prefab"), the backpack ("BackPack XRI.prefab") on the
/// shoulder and the hip/shoulder holsters (VrBodyAnchor "Shoulders"/"Waist" on the rig), chest slots
/// (VrChestSlots, lid opened by hand: VrHinge), NPC loot slots and doors (VrHinge).
/// Missing: ladders (4c) and hands (5).
/// (VrChestSlots, lid opened by hand: VrHinge), NPC loot slots, doors (VrHinge) and ladders (ClimbProvider
/// on the rig, ClimbInteractable + VrLadderExit on oCMobLadder).
/// Missing: hands (5).
/// </summary>
public class XriBackend : IVrBackend
{
Expand All @@ -25,8 +26,8 @@ public void InstallBindings(ContainerBuilder containerBuilder)
{
Logger.LogWarning("XRI backend is work in progress: rig, locomotion, input, haptics, UI laser pointers, " +
"screen fades, the XR Interaction Simulator, grabbing (items, mobs, NPCs), the " +
"backpack, holsters, chest slots (lid opens by using it) and NPC loot work. " +
"Physical doors/chest lids/ladders (4) and hands (5) are missing.", LogCat.VR);
"backpack, holsters, chest slots, doors, chest lids, ladders and NPC loot work. " +
"Hands (5) are missing.", LogCat.VR);

containerBuilder.AddSingleton(typeof(XriInput), typeof(IVrInput), typeof(XriInput));
containerBuilder.AddSingleton(typeof(XriHaptics), typeof(IVrHaptics));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ private void Awake()
Interactor.selectEntered.AddListener(OnSelectEntered);
Interactor.selectExited.AddListener(OnSelectExited);
_isSubscribed = true;

if (Interactor.farInteractionCaster is CurveInteractionCaster farCaster)
{
farCaster.castDistance = VRConstants.DistanceGrabMaxDistance;
farCaster.coneCastAngle = VRConstants.DistanceGrabConeAngle;
}
}

private void OnDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Interactables;
using UnityEngine.XR.Interaction.Toolkit.Interactors;
using UnityEngine.XR.Interaction.Toolkit.Locomotion.Climbing;
using Logger = Gothic.Core.Logging.Logger;

namespace Gothic.VR.Interaction.Backends.Xri
Expand Down Expand Up @@ -94,6 +95,11 @@ private void Start()

// Gothic meshes and their colliders are created at runtime, after XRI collected the colliders in Awake.
CollectColliders();

// The climb range (ClimbInteractable.maxInteractionDistance) is measured to the ladder's body.
if (_xrInteractable is ClimbInteractable)
_xrInteractable.getDistanceOverride = GetDistanceToBounds;

_xrInteractable.enabled = true;
}

Expand Down Expand Up @@ -179,6 +185,30 @@ private void CollectColliders()
Logger.LogWarning($"[XRI] {name} has no colliders. It can't be grabbed or hovered.", LogCat.VR);
}

/// <summary>
/// Distance to the colliders' bounds. XRI's own modes measure to the collider's transform (the ladder's base)
/// or need Collider.ClosestPoint, which Gothic's concave mesh colliders don't support.
/// </summary>
private DistanceInfo GetDistanceToBounds(IXRInteractable interactable, Vector3 position)
{
var result = new DistanceInfo { distanceSqr = float.MaxValue, point = position };
foreach (var itemCollider in interactable.colliders)
{
if (itemCollider == null || !itemCollider.enabled)
continue;

var distanceSqr = itemCollider.bounds.SqrDistance(position);
if (distanceSqr >= result.distanceSqr)
continue;

result.distanceSqr = distanceSqr;
result.point = itemCollider.bounds.ClosestPoint(position);
result.collider = itemCollider;
}

return result;
}

private VrGrabArgs CreateSelectArgs(IXRInteractor interactor)
{
if (interactor is Component component && component.TryGetComponent(out XriGrabberBridge grabber))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public class XriLineOfSightFilter : XRBaseTargetFilter
[Tooltip("Layers which block the line of sight.")]
[SerializeField] private LayerMask _blockingLayers = 1;

[Tooltip("Targets further away (m) can't be hovered or grabbed.")]
[SerializeField] private float _maxDistance = 10f;

[Tooltip("Targets closer to the hand (m) skip the check.")]
[SerializeField] private float _minCheckDistance = 0.15f;

Expand Down Expand Up @@ -56,7 +53,7 @@ private bool IsInLineOfSight(Vector3 origin, IXRInteractable target)

var toTarget = closestPoint - origin;
var distance = toTarget.magnitude;
if (distance > _maxDistance)
if (distance > VRConstants.DistanceGrabMaxDistance)
return false;

if (distance <= _minCheckDistance)
Expand Down
Loading