game(interaction): heaugh....
tricky...
This commit is contained in:
parent
ea08122ebd
commit
0fae85f09a
3 changed files with 324 additions and 1 deletions
|
@ -9,7 +9,11 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2632614413505857087}
|
||||
m_Layer: 0
|
||||
- component: {fileID: 3537147708043966638}
|
||||
- component: {fileID: 8698791976599484791}
|
||||
- component: {fileID: 7991227799423555426}
|
||||
- component: {fileID: 2726300989234573506}
|
||||
m_Layer: 10
|
||||
m_Name: Mark's Drawer Interactible (Dynamic Component)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -31,3 +35,268 @@ Transform:
|
|||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &3537147708043966638
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4851705267153564059}
|
||||
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
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4851705267153564059}
|
||||
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: 0
|
||||
m_VelocityDamping: 1
|
||||
m_VelocityScale: 0.5
|
||||
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!153 &2726300989234573506
|
||||
ConfigurableJoint:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4851705267153564059}
|
||||
m_ConnectedBody: {fileID: 0}
|
||||
m_ConnectedArticulationBody: {fileID: 0}
|
||||
m_Anchor: {x: 0, y: 0, z: 0}
|
||||
m_Axis: {x: 1, y: 0, z: 0}
|
||||
m_AutoConfigureConnectedAnchor: 1
|
||||
m_ConnectedAnchor: {x: 0, y: 0, z: 0}
|
||||
serializedVersion: 3
|
||||
m_SecondaryAxis: {x: 0, y: 1, z: 0}
|
||||
m_XMotion: 2
|
||||
m_YMotion: 2
|
||||
m_ZMotion: 2
|
||||
m_AngularXMotion: 2
|
||||
m_AngularYMotion: 2
|
||||
m_AngularZMotion: 2
|
||||
m_LinearLimitSpring:
|
||||
spring: 0
|
||||
damper: 0
|
||||
m_LinearLimit:
|
||||
limit: 0
|
||||
bounciness: 0
|
||||
contactDistance: 0
|
||||
m_AngularXLimitSpring:
|
||||
spring: 0
|
||||
damper: 0
|
||||
m_LowAngularXLimit:
|
||||
limit: 0
|
||||
bounciness: 0
|
||||
contactDistance: 0
|
||||
m_HighAngularXLimit:
|
||||
limit: 0
|
||||
bounciness: 0
|
||||
contactDistance: 0
|
||||
m_AngularYZLimitSpring:
|
||||
spring: 0
|
||||
damper: 0
|
||||
m_AngularYLimit:
|
||||
limit: 0
|
||||
bounciness: 0
|
||||
contactDistance: 0
|
||||
m_AngularZLimit:
|
||||
limit: 0
|
||||
bounciness: 0
|
||||
contactDistance: 0
|
||||
m_TargetPosition: {x: 0, y: 0, z: 0}
|
||||
m_TargetVelocity: {x: 0, y: 0, z: 0}
|
||||
m_XDrive:
|
||||
serializedVersion: 4
|
||||
positionSpring: 0
|
||||
positionDamper: 0
|
||||
maximumForce: 3.4028233e+38
|
||||
useAcceleration: 0
|
||||
m_YDrive:
|
||||
serializedVersion: 4
|
||||
positionSpring: 0
|
||||
positionDamper: 0
|
||||
maximumForce: 3.4028233e+38
|
||||
useAcceleration: 0
|
||||
m_ZDrive:
|
||||
serializedVersion: 4
|
||||
positionSpring: 0
|
||||
positionDamper: 0
|
||||
maximumForce: 3.4028233e+38
|
||||
useAcceleration: 0
|
||||
m_TargetRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_TargetAngularVelocity: {x: 0, y: 0, z: 0}
|
||||
m_RotationDriveMode: 0
|
||||
m_AngularXDrive:
|
||||
serializedVersion: 4
|
||||
positionSpring: 0
|
||||
positionDamper: 0
|
||||
maximumForce: 3.4028233e+38
|
||||
useAcceleration: 0
|
||||
m_AngularYZDrive:
|
||||
serializedVersion: 4
|
||||
positionSpring: 0
|
||||
positionDamper: 0
|
||||
maximumForce: 3.4028233e+38
|
||||
useAcceleration: 0
|
||||
m_SlerpDrive:
|
||||
serializedVersion: 4
|
||||
positionSpring: 0
|
||||
positionDamper: 0
|
||||
maximumForce: 3.4028233e+38
|
||||
useAcceleration: 0
|
||||
m_ProjectionMode: 0
|
||||
m_ProjectionDistance: 0.1
|
||||
m_ProjectionAngle: 180
|
||||
m_ConfiguredInWorldSpace: 0
|
||||
m_SwapBodies: 0
|
||||
m_BreakForce: Infinity
|
||||
m_BreakTorque: Infinity
|
||||
m_EnableCollision: 0
|
||||
m_EnablePreprocessing: 1
|
||||
m_MassScale: 1
|
||||
m_ConnectedMassScale: 1
|
||||
|
|
43
Game/Assets/Scripts/DrawerDynamicJointConfiguration.cs
Normal file
43
Game/Assets/Scripts/DrawerDynamicJointConfiguration.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class DrawerDynamicJointConfiguration : MonoBehaviour
|
||||
{
|
||||
public 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
|
||||
};
|
||||
}
|
||||
}
|
11
Game/Assets/Scripts/DrawerDynamicJointConfiguration.cs.meta
Normal file
11
Game/Assets/Scripts/DrawerDynamicJointConfiguration.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: da315c3f1e28be241badd4ee9c4b6e76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Reference in a new issue