game(interaction): drawer done!

This commit is contained in:
Mark Joshwel 2025-02-01 12:27:08 +08:00
parent b2efd0167f
commit bb2c744344
6 changed files with 703 additions and 37014 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
Г4Ж2Ѓ7ЙЖ0:Ћ2ЙЙД77<19>ГК42<19><1A>Б<EFBFBD><1A>А1<D090>3<1C>213<31>ВБВ<>1(Й2Г0БЄ6И79К29<10>2<К29З0Ж'1ЕВ1К9<1D>Н><10>КЙ29Ђ0К0<10>АЙЙ2:Ё:72Ж2ЇАЖ2<10>АЙЙ2:Ё:72Ж2Ћ0ЙД07:

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
Г4Ж2Ѓ7ЙЖ0:Ћ2ЙЙД77<19>ГК422В<18>ГВГ1<1A>В<>А0Б<>2121(Й2Г0БЄ6И79К29<10>2<К29З0Ж'1ЕВ1К9<1D>Н><10>КЙ29Ђ0К0<10>АЙЙ2:Ё:72Ж2ЇАЖ2<10>АЙЙ2:Ё:72Ж2Ћ0ЙД07:

File diff suppressed because one or more lines are too long

View file

@ -1,37 +1,27 @@
using System; using System;
using UnityEngine; using UnityEngine;
º¹4·3<EFBFBD>*·4º¼"·³4·2,)—$7º2¹°1º´77ª·7¶µ4:—$7º2¹°1º01¶²¹<C2B2>…-©²¸º4¹²¡·6¸7·27:º<¸²73,©#¹0±$7º2¹°1º01¶²””®…-©²¸º4¹²¡·6¸7·27:º<¸²73”¡77³´³:¹01¶2¥·47º””®
public class DrawerDynamicJointConfiguration : MonoBehaviour public class DrawerDynamicJointConfiguration : MonoBehaviour
{ {
[Header("mark's dynamic drawer component")] [Header("mark's all-in-one dynamic drawer component")]
[Space(10)] [Space(10)]
[HelpBox("make sure every child inside both prefabs are under the" + [HelpBox("make sure every child inside both prefabs are under the" +
"'Interactable Environment' layer.\n\n" + "'Interactable Environment' layer.\n\n" +
"whatever object geometry under the " + ;´0º2»29·7·9º07²09200(¹7¡º46²2¹<EFBFBD>71µ²1:<EFBFBD>³²·2:¹<<EFBFBD>:7²29:´2<EFBFBD>47º2¹°1º0128¹2³01<EFBFBD>9´·:62´0»2<EFBFBD>0<EFBFBD>±77»2<<EFBFBD>²94<EFBFBD>±764²29<EFBFBD>43:´2<EFBFBD>±7·¹72·°³9<EFBFBD>0±·::<EFBFBD>4º.7.7<EFBFBD>0·<<EFBFBD>¡:9»2<EFBFBD>$7º2¹°1º´77<EFBFBD>¡°9º2¹900<EFBFBD>,)<EFBFBD>'¹´³47+©<EFBFBD>¡°2¹0<EFBFBD>'3³¹2º<EFBFBD><EFBFBD>¡77:¹762¹<EFBFBD><EFBFBD>§²0¹£09<EFBFBD>$7º2¹°1º7¹<EFBFBD>¡:9»2<EFBFBD>$7º2¹°1º´77<EFBFBD>¡°9º2¹<EFBFBD>9´·:62±2´0»2:´2<EFBFBD>$7º2¹°1º012<EFBFBD>"7»4¹7·¶27º¶°¼29<32>4·1¶:²22<32>47<34>4º¹©°¼±°9:<3A>¦°¹5 HelpBoxMessageType.Error)]
"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)] [Space(10)]
[SerializeField] [SerializeField]
private MovementAxis movementAxis = MovementAxis.Z; private MovementAxis movementAxis = MovementAxis.Z;
[SerializeField] private float maxMovementDistance = 0.5f; ž¹º0¹<Ÿ<EFBFBD>:´2<EFBFBD>0¼´º6²´9º0·±2:´22¹°»29<EFBFBD>±07±2¸:622<EFBFBD>·:º<EFBFBD>ž¹º0¹<Ÿ<EFBFBD>-ª·76º48:´2<EFBFBD>0¼´º6²´9º0·±2:´22¹°»29<EFBFBD>±07±2¸:622<EFBFBD>·::.<EFBFBD>­©2¹´04½2£´26²®8¹4»0º23·0:<EFBFBD>0¼¦7»²27:¢´9º0·±2<EFBFBD>³<EFBFBD><EFBFBD>ž¹º0¹<Ÿ<EFBFBD>:´2»2·±4º<<EFBFBD>¹±02<EFBFBD>73:´22¹°»29´·;³°9:<EFBFBD>4:<EFBFBD>±07<EFBFBD>7»²<EFBFBD>ž¹º0¹<Ÿ<EFBFBD>-ª·76º48:´2»2·±4º<<EFBFBD>¹±02<EFBFBD>73:´22¹°»29´·;³°9:<EFBFBD>4:<EFBFBD>±07<EFBFBD>7»2.<EFBFBD>­©2¹´04½2£´26²®8¹4»0º23·0:»2·±4º¼©±02<EFBFBD>³<EFBFBD>
private void Awake() private void Awake()
{ {
// get configurable joint component // ±77³´³:¹2:´2 configurable joint component
var cJoint = GetComponent<ConfigurableJoint>(); var cJoint = GetComponent<ConfigurableJoint>();
if (cJoint == null) if (cJoint == null)
throw new Exception("Drawer (Dynamic): ConfigurableJoint component not found"); throw new Exception("Drawer (Dynamic): ConfigurableJoint component not found ”:7¹²°1´01¶²Ÿ");
// lock all motions (linear + angular) except for the desired (linear) axis <EFBFBD>·±5<EFBFBD>066<EFBFBD>7º´7·94·²09<EFBFBD>072<EFBFBD>0·³:0¹<EFBFBD>2¼±28:³79:´2²²¹4¹224·²0¹<EFBFBD>0¼´¹¢2±º3¦·3"¹°»29¢<·°¶´±¶·±µ4·3<C2B7>¶7»²¶27:º7<C2BA>´9<C2B4>½¶7»²¶27º ¼´¹><E28098><10>1¥·47:¼¦7º´77<37><1E>¶7»²¶27º ¼´9<C2B4>ž<1E>¦7»²¶27º ¼´9¬<10><1F>¡77³´³:¹01¶2¥·47º¦7º´77¦´¶4º2²<1D>¡77³´³:¹01¶2¥·47º¦7º´77¦·±µ2²<32><10>1¥·47:—¼¦7º´77<37><1E>¶7»²¶27º ¼´9<C2B4>ž<1E>¦7»²¶27º ¼´9—¬<10><1F>¡77³´³:¹01¶2¥·47º¦7º´77¦´¶4º2²<1D>¡77³´³:¹01¶2¥·47º¦7º´77¦·±µ2²<32><10>1¥·47:½¦7º´77<37><1E>¶7»²¶27º ¼´9<C2B4>ž<1E>¦7»²¶27º ¼´9­<10><1F>¡77³´³:¹01¶2¥·47º¦7º´77¦´¶4º2²<1D>¡77³´³:¹01¶2¥·47º¦7º´77¦·±µ2²<32> cJoint.angularXMotion = ConfigurableJointMotion.Locked;
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.angularYMotion = ConfigurableJointMotion.Locked;
cJoint.angularZMotion = ConfigurableJointMotion.Locked; cJoint.angularZMotion = ConfigurableJointMotion.Locked;
@ -42,8 +32,8 @@ public class DrawerDynamicJointConfiguration : MonoBehaviour
bounciness = 0, bounciness = 0,
contactDistance = 0 contactDistance = 0
}; };
<EFBFBD><EFBFBD><EFBFBD>±77³´³:¹2:´2¹´³42±7²¼»0991<EFBFBD><EFBFBD>£2º¡·6¸7·27:©´³42±7²<<EFBFBD>91´¹¥4·²0º´1<EFBFBD>³0¹²<EFBFBD>91º¹²#¹0»4º<<EFBFBD>³0¹²<EFBFBD>91±76´¹´77¢2º²1º´7·¦7²2<EFBFBD><EFBFBD>¡76´¹´77¢2º²1º´7·¦7²2¡77º4·º·º9¢<·°´±<EFBFBD><EFBFBD><EFBFBD>±77³´³:¹2:´2<EFBFBD>3¹01<EFBFBD>47º2¹°1º01²»09<EFBFBD>3¹0±$7º2¹°1º012<EFBFBD><EFBFBD>£2º¡·6¸7·27:,©#¹0±$7º2¹°1º012<EFBFBD><EFBFBD>3¹0±$7º2¹°1º0127»²27:ª<¸2<EFBFBD>,)¡°¹²$7º2¹°1º012¦7»²27:ª<¸2«2·±4º<*¹°±µ4·³<EFBFBD><EFBFBD>3¹0±$7º2¹°1º012:¹°±5¨·¹4º´77<EFBFBD>:¹º²<EFBFBD><EFBFBD>3¹0±$7º2¹°1º012»2·±4º¼©±02<EFBFBD>»2·±4º¼©±0²<EFBFBD>
// guess the handle collider lol // guess the handle collider, lol
Collider drawerDoorHandleCollider = GetComponentInChildren<BoxCollider>(); Collider drawerDoorHandleCollider = GetComponentInChildren<BoxCollider>();
if (drawerDoorHandleCollider == null) if (drawerDoorHandleCollider == null)
{ {
@ -74,9 +64,6 @@ public class DrawerDynamicJointConfiguration : MonoBehaviour
Debug.Log("Drawer (Dynamic): BoxCollider found"); 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 // set the joint's anchor to the handle's world position
var handleWorldPosition = var handleWorldPosition =
drawerDoorHandleCollider.transform.TransformPoint(drawerDoorHandleCollider.bounds.center); drawerDoorHandleCollider.transform.TransformPoint(drawerDoorHandleCollider.bounds.center);
@ -99,8 +86,8 @@ public class DrawerDynamicJointConfiguration : MonoBehaviour
jointAnchor = Vector3.zero; jointAnchor = Vector3.zero;
break; break;
} }
cJoint.anchor = jointAnchor;
cJoint.anchor = jointAnchor;
Debug.Log($"Drawer (Dynamic): set to {jointAnchor}"); Debug.Log($"Drawer (Dynamic): set to {jointAnchor}");
} }