game(interaction): JUST LET ME GRAAAB EMMMM

PLEEEAAAASEEEEE
This commit is contained in:
Mark Joshwel 2025-02-01 03:16:41 +08:00
parent 0fae85f09a
commit cca03f48f8
6 changed files with 37022 additions and 1197 deletions

View file

@ -1,6 +1,6 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4851705267153564059
--- !u!1 &2785014689676826087
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -8,81 +8,54 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2632614413505857087}
- component: {fileID: 3537147708043966638}
- component: {fileID: 8698791976599484791}
- component: {fileID: 7991227799423555426}
- component: {fileID: 2726300989234573506}
- component: {fileID: 7548123659046493114}
- component: {fileID: 9107066153244540908}
- component: {fileID: 2929167475790662953}
- component: {fileID: 3082934515490353905}
- component: {fileID: 1033763107808798454}
m_Layer: 10
m_Name: Mark's Drawer Interactible (Dynamic Component)
m_Name: Drawer Interactable (Dynamic Component)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2632614413505857087
--- !u!4 &7548123659046493114
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4851705267153564059}
m_GameObject: {fileID: 2785014689676826087}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.876619, y: -0.17838104, z: 3.1508512}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3537147708043966638
--- !u!114 &9107066153244540908
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4851705267153564059}
m_GameObject: {fileID: 2785014689676826087}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: da315c3f1e28be241badd4ee9c4b6e76, type: 3}
m_Name:
m_EditorClassIdentifier:
movementAxis: 2
maxDistance: 0.5
--- !u!54 &8698791976599484791
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4851705267153564059}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 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: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &7991227799423555426
movementAxis: 1
maxMovementDistance: 0.5
--- !u!114 &2929167475790662953
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4851705267153564059}
m_GameObject: {fileID: 2785014689676826087}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ad34abafad169848a38072baa96cdb2, type: 3}
@ -198,16 +171,43 @@ MonoBehaviour:
m_StartingMultipleGrabTransformers: []
m_AddDefaultGrabTransformers: 1
m_FarAttachMode: 0
--- !u!153 &2726300989234573506
--- !u!54 &3082934515490353905
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2785014689676826087}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 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!153 &1033763107808798454
ConfigurableJoint:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4851705267153564059}
m_GameObject: {fileID: 2785014689676826087}
m_ConnectedBody: {fileID: 0}
m_ConnectedArticulationBody: {fileID: 0}
m_Anchor: {x: 0, y: 0, z: 0}
m_Anchor: {x: 0, y: -0.25, z: 0}
m_Axis: {x: 1, y: 0, z: 0}
m_AutoConfigureConnectedAnchor: 1
m_ConnectedAnchor: {x: 0, y: 0, z: 0}

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c540786aac44eb0429884d6b3c362401
guid: b4c150a76357ddf4c8164a72e74104ec
PrefabImporter:
externalObjects: {}
userData:

View file

@ -1,268 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7996569783472804039
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1655799441469573623}
m_Layer: 10
m_Name: Mark's Drawer Interactable (Dynamic Component)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1655799441469573623
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7996569783472804039}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.876619, y: -0.17838104, z: 3.1508512}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7116421329001886975}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1346123964617294432
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1655799441469573623}
m_Modifications:
- target: {fileID: 312346524704041383, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_Name
value: Counter_Reza
objectReference: {fileID: 0}
- target: {fileID: 5058509910333861203, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalPosition.x
value: 0.203
objectReference: {fileID: 0}
- target: {fileID: 5058509910333861203, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalPosition.y
value: 0.053
objectReference: {fileID: 0}
- target: {fileID: 5058509910333861203, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalPosition.z
value: -0.79
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalPosition.x
value: -0.498619
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalPosition.y
value: 0.738381
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalPosition.z
value: -0.07685137
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalRotation.w
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalRotation.x
value: -0.50000006
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalRotation.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalRotation.z
value: -0.5
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 8313008103358155315, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
insertIndex: -1
addedObject: {fileID: 7228632606091979765}
- targetCorrespondingSourceObject: {fileID: 8313008103358155315, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
insertIndex: -1
addedObject: {fileID: 7021593165233705035}
m_SourcePrefab: {fileID: 100100000, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
--- !u!1 &7058222872572774483 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8313008103358155315, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
m_PrefabInstance: {fileID: 1346123964617294432}
m_PrefabAsset: {fileID: 0}
--- !u!54 &7228632606091979765
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7058222872572774483}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 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: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &7021593165233705035
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7058222872572774483}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ad34abafad169848a38072baa96cdb2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_InteractionManager: {fileID: 0}
m_Colliders: []
m_InteractionLayers:
m_Bits: 1
m_DistanceCalculationMode: 1
m_SelectMode: 0
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_AttachTransform: {fileID: 0}
m_SecondaryAttachTransform: {fileID: 0}
m_UseDynamicAttach: 0
m_MatchAttachPosition: 1
m_MatchAttachRotation: 1
m_SnapToColliderVolume: 1
m_ReinitializeDynamicAttachEverySingleGrab: 1
m_AttachEaseInTime: 0.15
m_MovementType: 2
m_VelocityDamping: 1
m_VelocityScale: 1
m_AngularVelocityDamping: 1
m_AngularVelocityScale: 1
m_TrackPosition: 1
m_SmoothPosition: 0
m_SmoothPositionAmount: 8
m_TightenPosition: 0.1
m_TrackRotation: 1
m_SmoothRotation: 0
m_SmoothRotationAmount: 8
m_TightenRotation: 0.1
m_TrackScale: 1
m_SmoothScale: 0
m_SmoothScaleAmount: 8
m_TightenScale: 0.1
m_ThrowOnDetach: 1
m_ThrowSmoothingDuration: 0.25
m_ThrowSmoothingCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_ThrowVelocityScale: 1.5
m_ThrowAngularVelocityScale: 1
m_ForceGravityOnDetach: 0
m_RetainTransformParent: 1
m_StartingSingleGrabTransformers: []
m_StartingMultipleGrabTransformers: []
m_AddDefaultGrabTransformers: 1
m_FarAttachMode: 0
--- !u!4 &7116421329001886975 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 8101131182664332959, guid: f08520c74595f984ca1507db4e8aaa41, type: 3}
m_PrefabInstance: {fileID: 1346123964617294432}
m_PrefabAsset: {fileID: 0}

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 64158955387fbac419661891e01f9719
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View file

@ -3,41 +3,111 @@ using UnityEngine;
public class DrawerDynamicJointConfiguration : MonoBehaviour
{
public enum MovementAxis
[Header("mark's dynamic drawer component")]
[Space(10)]
[HelpBox("make sure every child inside both prefabs are under the" +
"'Interactable Environment' layer.\n\n" +
"whatever object geometry under the " +
"interactable prefab should have a convex mesh collider!\n\n" +
"any physics silliness may be fixable by adjusting the XR Grab Interactable " +
"> Track Position > Velocity Scale\n\n" +
"ANY immediate children objects must have their transforms reset to 0 0 0 " +
"so that the ConfigurableJoint would be positioned correctly",
HelpBoxMessageType.Error)]
[Space(10)]
[SerializeField]
private MovementAxis movementAxis = MovementAxis.Z;
[SerializeField] private float maxMovementDistance = 0.5f;
private void Awake()
{
// get configurable joint component
var cJoint = GetComponent<ConfigurableJoint>();
if (cJoint == null)
throw new Exception("Drawer (Dynamic): ConfigurableJoint component not found");
// lock all motions (linear + angular) except for the desired (linear) axis
cJoint.xMotion = movementAxis == MovementAxis.X ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
cJoint.yMotion = movementAxis == MovementAxis.Y ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
cJoint.zMotion = movementAxis == MovementAxis.Z ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
cJoint.angularXMotion = ConfigurableJointMotion.Locked;
cJoint.angularYMotion = ConfigurableJointMotion.Locked;
cJoint.angularZMotion = ConfigurableJointMotion.Locked;
// set linear limit
cJoint.linearLimit = new SoftJointLimit
{
limit = maxMovementDistance,
bounciness = 0,
contactDistance = 0
};
// guess the handle collider lol
Collider drawerDoorHandleCollider = GetComponentInChildren<BoxCollider>();
if (drawerDoorHandleCollider == null)
{
drawerDoorHandleCollider = GetComponentInChildren<SphereCollider>();
if (drawerDoorHandleCollider == null)
{
drawerDoorHandleCollider = GetComponentInChildren<CapsuleCollider>();
if (drawerDoorHandleCollider == null)
{
drawerDoorHandleCollider = GetComponentInChildren<MeshCollider>();
if (drawerDoorHandleCollider == null)
throw new Exception("Drawer (Dynamic): Drawer door handle collider not found");
Debug.Log("Drawer (Dynamic): MeshCollider collider found");
}
else
{
Debug.Log("Drawer (Dynamic): CapsuleCollider found");
}
}
else
{
Debug.Log("Drawer (Dynamic): SphereCollider found");
}
}
else
{
Debug.Log("Drawer (Dynamic): BoxCollider found");
}
// prevent the joint from moving the connected body to the joint's anchor
// cj.autoConfigureConnectedAnchor = false;
// set the joint's anchor to the handle's world position
var handleWorldPosition =
drawerDoorHandleCollider.transform.TransformPoint(drawerDoorHandleCollider.bounds.center);
var jointAnchor = cJoint.transform.InverseTransformPoint(handleWorldPosition);
switch (movementAxis)
{
case MovementAxis.X:
jointAnchor.y = 0;
jointAnchor.z = 0;
break;
case MovementAxis.Y:
jointAnchor.x = 0;
jointAnchor.z = 0;
break;
case MovementAxis.Z:
jointAnchor.x = 0;
jointAnchor.y = 0;
break;
default:
jointAnchor = Vector3.zero;
break;
}
cJoint.anchor = jointAnchor;
Debug.Log($"Drawer (Dynamic): set to {jointAnchor}");
}
private enum MovementAxis
{
X,
Y,
Z
}
[Header("mark's dynamic drawer component")]
[Space(10)]
[HelpBox("make sure every child inside both prefabs are under the 'Interactable Environment' layer, thx", HelpBoxMessageType.Warning)]
[Space(10)]
[SerializeField] private MovementAxis movementAxis = MovementAxis.Z;
[SerializeField] private float maxDistance = 0.5f;
private void Awake()
{
// get configurable joint component
var cj = GetComponent<ConfigurableJoint>();
if (cj == null)
throw new Exception("Drawer (Dynamic): ConfigurableJoint component not found");
// lock all motions (linear + angular) except for the desired (linear) axis
cj.xMotion = movementAxis == MovementAxis.X ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
cj.yMotion = movementAxis == MovementAxis.Y ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
cj.zMotion = movementAxis == MovementAxis.Z ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
cj.angularXMotion = ConfigurableJointMotion.Locked;
cj.angularYMotion = ConfigurableJointMotion.Locked;
cj.angularZMotion = ConfigurableJointMotion.Locked;
// set linear limit
cj.linearLimit = new SoftJointLimit
{
limit = maxDistance,
bounciness = 0,
contactDistance = 0
};
}
}