Improved doors. This introduced ghost hand issue and some doors being hinged backwards. Working on it.

This commit is contained in:
2025-12-16 15:50:55 +02:00
parent 98526fd582
commit c999bafa22
8 changed files with 488 additions and 6 deletions

View File

@@ -0,0 +1,240 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Handle turn
serializedVersion: 7
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: {x: -90, y: 0, z: 0}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
- serializedVersion: 3
time: 0.33333334
value: {x: -90, y: 35, z: 0}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
- serializedVersion: 3
time: 0.6666667
value: {x: -90, y: 0, z: 0}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
path:
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 4
script: {fileID: 0}
typeID: 4
customType: 4
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.6666667
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -90
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: -90
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.6666667
value: -90
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.x
path:
classID: 4
script: {fileID: 0}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 35
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.6666667
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.y
path:
classID: 4
script: {fileID: 0}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.6666667
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.z
path:
classID: 4
script: {fileID: 0}
flags: 0
m_EulerEditorCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.x
path:
classID: 4
script: {fileID: 0}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.y
path:
classID: 4
script: {fileID: 0}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.z
path:
classID: 4
script: {fileID: 0}
flags: 0
m_HasGenericRootTransform: 1
m_HasMotionFloatCurves: 0
m_Events: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 50462337bf29890408d9ae8bb3266c3f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,156 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1107 &-1069537623632272288
AnimatorStateMachine:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 3989251228479606634}
m_Position: {x: 458, y: 258, z: 0}
- serializedVersion: 1
m_State: {fileID: 3688584692115086133}
m_Position: {x: 250, y: 430, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 690, y: 0, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 3989251228479606634}
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Handle
serializedVersion: 5
m_AnimatorParameters:
- m_Name: TurnHandle
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: -1069537623632272288}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &406386627949578915
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 3989251228479606634}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0.24650171
m_ExitTime: 0.98950523
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &3688584692115086133
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Handle turn
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 406386627949578915}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 50462337bf29890408d9ae8bb3266c3f, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &3989251228479606634
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New State
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 4639235367011125292}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 0}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &4639235367011125292
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: TurnHandle
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 3688584692115086133}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dff939b7bd92e7a49878acde7e3f25e1
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -93,23 +93,27 @@ namespace _PROJECT.NewHandPresence
break; break;
case TutorialState.Turn: case TutorialState.Turn:
ShowTurnHint(); ShowTurnHint();
SetControllerVisibility(true);
break; break;
case TutorialState.Move: case TutorialState.Move:
ShowLocomotionHint(); ShowLocomotionHint();
SetControllerVisibility(true);
break; break;
case TutorialState.Teleport: case TutorialState.Teleport:
ShowTeleportHint(); ShowTeleportHint();
SetControllerVisibility(true);
break; break;
case TutorialState.WaitForGrip: case TutorialState.WaitForGrip:
//SetHandsVisibility(true); SetControllerVisibility(false);
break; break;
case TutorialState.Grip: case TutorialState.Grip:
//SetHandsVisibility(false); //SetHandsVisibility(false);
CreateBillboard(_grabInteractable.gameObject, "Grab me!"); CreateBillboard(_grabInteractable.gameObject, "Grab me!");
ShowGripHint(); ShowGripHint();
SetControllerVisibility(true);
break; break;
case TutorialState.Done: case TutorialState.Done:
//SetHandsVisibility(true); SetControllerVisibility(false);
DestroyBillboard(); DestroyBillboard();
break; break;
default: default:

View File

@@ -1,6 +1,7 @@
using _PROJECT.NewHandPresence; using _PROJECT.NewHandPresence;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems;
public enum GrabbingHand public enum GrabbingHand
{ {
@@ -12,6 +13,10 @@ public class DoorHandReplacer : MonoBehaviour
{ {
public GameObject LeftHand; public GameObject LeftHand;
public GameObject RightHand; public GameObject RightHand;
public GameObject DoorSlab;
public GameObject handle;
public float DoorClosedTolerance = 5f;
private GrabbingHand? hand = null; // nullable private GrabbingHand? hand = null; // nullable
private SmartHandPresence currentHand = null; private SmartHandPresence currentHand = null;
@@ -23,6 +28,10 @@ public class DoorHandReplacer : MonoBehaviour
public void ManifestDoorHand() public void ManifestDoorHand()
{ {
if (currentHand == null || hand == null) return; if (currentHand == null || hand == null) return;
isGrabbing = true; isGrabbing = true;
switch (hand.Value) switch (hand.Value)
{ {
@@ -38,6 +47,17 @@ public class DoorHandReplacer : MonoBehaviour
Debug.Log("Dissapearing hand"); Debug.Log("Dissapearing hand");
break; break;
} }
float doorSlabRotation = DoorSlab.transform.localRotation.y;
if (Mathf.Abs(doorSlabRotation) < Mathf.Abs(DoorClosedTolerance)) // If door is closed
{
Animator animator = handle.GetComponent<Animator>();
if (animator != null)
{
animator.SetTrigger("TurnHandle");
}
}
} }
public void DeManifestDoorHand() public void DeManifestDoorHand()
@@ -50,6 +70,22 @@ public class DoorHandReplacer : MonoBehaviour
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
{ {
if (isGrabbing && other.GetComponentInParent<HandPresencePhysics>() != null) {
if (other.gameObject.name.Contains("left", System.StringComparison.OrdinalIgnoreCase))
{
if (hand == GrabbingHand.Left) DeManifestDoorHand();
isGrabbing = false;
return;
}
else if (other.gameObject.name.Contains("right", System.StringComparison.OrdinalIgnoreCase))
{
if (hand == GrabbingHand.Right) DeManifestDoorHand();
isGrabbing = false;
return;
}
}
if (isGrabbing) return; if (isGrabbing) return;
// IMPORTANT: in case hands have multiple colliders // IMPORTANT: in case hands have multiple colliders
@@ -104,5 +140,7 @@ public class DoorHandReplacer : MonoBehaviour
} }
} }
} }

View File

@@ -2049,6 +2049,9 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
LeftHand: {fileID: 3653856938231415728} LeftHand: {fileID: 3653856938231415728}
RightHand: {fileID: 3103255069014892412} RightHand: {fileID: 3103255069014892412}
DoorSlab: {fileID: 7524997068079331246}
handle: {fileID: 8144616511261564589}
DoorClosedTolerance: 2
--- !u!1 &3833539609118016623 --- !u!1 &3833539609118016623
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -3196,6 +3199,9 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
LeftHand: {fileID: 8103609142261368991} LeftHand: {fileID: 8103609142261368991}
RightHand: {fileID: 8840218683010281881} RightHand: {fileID: 8840218683010281881}
DoorSlab: {fileID: 7524997068079331246}
handle: {fileID: 8144616511261564589}
DoorClosedTolerance: 2
--- !u!1 &6679012744063801158 --- !u!1 &6679012744063801158
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -4495,6 +4501,7 @@ GameObject:
- component: {fileID: 3498540873281038041} - component: {fileID: 3498540873281038041}
- component: {fileID: 5011201851681782278} - component: {fileID: 5011201851681782278}
- component: {fileID: 4750052106936640280} - component: {fileID: 4750052106936640280}
- component: {fileID: 2573521784815233397}
m_Layer: 0 m_Layer: 0
m_Name: Handle m_Name: Handle
m_TagString: Untagged m_TagString: Untagged
@@ -4509,7 +4516,7 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8144616511261564589} m_GameObject: {fileID: 8144616511261564589}
m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071067} m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 12, y: 2.5, z: 1} m_LocalScale: {x: 12, y: 2.5, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
@@ -4519,7 +4526,7 @@ Transform:
- {fileID: 5932402600523855724} - {fileID: 5932402600523855724}
m_Father: {fileID: 9007664768440961826} m_Father: {fileID: 9007664768440961826}
m_RootOrder: -1 m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!33 &3498540873281038041 --- !u!33 &3498540873281038041
MeshFilter: MeshFilter:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -4591,6 +4598,27 @@ BoxCollider:
serializedVersion: 3 serializedVersion: 3
m_Size: {x: 0.010000005, y: 0.010000025, z: 0.19003801} m_Size: {x: 0.010000005, y: 0.010000025, z: 0.19003801}
m_Center: {x: 0.0038245337, y: 0.00049417425, z: 0.0009743291} m_Center: {x: 0.0038245337, y: 0.00049417425, z: 0.0009743291}
--- !u!95 &2573521784815233397
Animator:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8144616511261564589}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: dff939b7bd92e7a49878acde7e3f25e1, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &8279875726491709949 --- !u!1 &8279875726491709949
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0