1
0
mirror of synced 2024-11-24 06:40:11 +01:00

add hand stabilization (velocity)

This commit is contained in:
xpeng 2022-10-16 15:42:49 +02:00
parent 6803f5c905
commit 014cebe156
7 changed files with 457 additions and 12 deletions

View File

@ -0,0 +1,131 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-3505891184086349949
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HandVirtual
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
m_ValidKeywords:
- _SURFACE_TYPE_TRANSPARENT
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3050
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- DepthOnly
- SHADOWCASTER
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BlendOp: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 50
- _ReceiveShadows: 1
- _SampleGI: 0
- _Smoothness: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _Surface: 1
- _WorkflowMode: 1
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 0.5283019, g: 0.5283019, b: 0.5283019, a: 0.101960786}
- _Color: {r: 0.5283019, g: 0.5283019, b: 0.5283019, a: 0.101960786}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

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

View File

@ -3458,6 +3458,7 @@ GameObject:
- component: {fileID: 587127953} - component: {fileID: 587127953}
- component: {fileID: 587127952} - component: {fileID: 587127952}
- component: {fileID: 587127951} - component: {fileID: 587127951}
- component: {fileID: 587127957}
- component: {fileID: 587127956} - component: {fileID: 587127956}
m_Layer: 0 m_Layer: 0
m_Name: RHand m_Name: RHand
@ -3478,8 +3479,8 @@ Transform:
m_LocalScale: {x: 0.07, y: 0.07, z: 0.07} m_LocalScale: {x: 0.07, y: 0.07, z: 0.07}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 2135367910} m_Father: {fileID: 771549578}
m_RootOrder: 0 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!135 &587127951 --- !u!135 &587127951
SphereCollider: SphereCollider:
@ -3575,6 +3576,22 @@ MonoBehaviour:
Hand: 5 Hand: 5
duration: 0.1 duration: 0.1
amplitude: 1 amplitude: 1
--- !u!114 &587127957
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 587127949}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 21fbb267de3292549be7c4a22d42cc53, type: 3}
m_Name:
m_EditorClassIdentifier:
Target: {fileID: 1862938722}
Center: {fileID: 2020549004}
Mode: 0
VelocityThreshold: 0.5
--- !u!114 &588690909 --- !u!114 &588690909
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -4377,6 +4394,8 @@ Transform:
- {fileID: 2095231903} - {fileID: 2095231903}
- {fileID: 1978608052} - {fileID: 1978608052}
- {fileID: 2135367910} - {fileID: 2135367910}
- {fileID: 587127950}
- {fileID: 918186759}
m_Father: {fileID: 1944661008} m_Father: {fileID: 1944661008}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -5126,6 +5145,7 @@ GameObject:
- component: {fileID: 918186762} - component: {fileID: 918186762}
- component: {fileID: 918186761} - component: {fileID: 918186761}
- component: {fileID: 918186760} - component: {fileID: 918186760}
- component: {fileID: 918186766}
- component: {fileID: 918186765} - component: {fileID: 918186765}
m_Layer: 0 m_Layer: 0
m_Name: LHand m_Name: LHand
@ -5146,8 +5166,8 @@ Transform:
m_LocalScale: {x: 0.07, y: 0.07, z: 0.07} m_LocalScale: {x: 0.07, y: 0.07, z: 0.07}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 1978608052} m_Father: {fileID: 771549578}
m_RootOrder: 0 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!135 &918186760 --- !u!135 &918186760
SphereCollider: SphereCollider:
@ -5243,6 +5263,22 @@ MonoBehaviour:
Hand: 4 Hand: 4
duration: 0.1 duration: 0.1
amplitude: 1 amplitude: 1
--- !u!114 &918186766
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 918186758}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 21fbb267de3292549be7c4a22d42cc53, type: 3}
m_Name:
m_EditorClassIdentifier:
Target: {fileID: 1542244747}
Center: {fileID: 2020549004}
Mode: 0
VelocityThreshold: 0.5
--- !u!65 &922637051 --- !u!65 &922637051
BoxCollider: BoxCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -9216,6 +9252,106 @@ BoxCollider:
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 0.00038862787, y: 0.0006574618, z: 0.0028851903} m_Size: {x: 0.00038862787, y: 0.0006574618, z: 0.0028851903}
m_Center: {x: -7.2240197e-10, y: -0.000006444839, z: -0.0014039767} m_Center: {x: -7.2240197e-10, y: -0.000006444839, z: -0.0014039767}
--- !u!1 &1542244747
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1542244751}
- component: {fileID: 1542244750}
- component: {fileID: 1542244749}
- component: {fileID: 1542244748}
m_Layer: 0
m_Name: LHand Virtual
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!54 &1542244748
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1542244747}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!23 &1542244749
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1542244747}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 0cd754e6b14972d4aa8161f01e35dd98, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &1542244750
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1542244747}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1542244751
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1542244747}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.07, y: 0.07, z: 0.07}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1978608052}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1542680180 --- !u!114 &1542680180
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -27983,6 +28119,106 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
LightManager: {fileID: 1251312951} LightManager: {fileID: 1251312951}
--- !u!1 &1862938722
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1862938726}
- component: {fileID: 1862938725}
- component: {fileID: 1862938724}
- component: {fileID: 1862938723}
m_Layer: 0
m_Name: RHand Virtual
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!54 &1862938723
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1862938722}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!23 &1862938724
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1862938722}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 0cd754e6b14972d4aa8161f01e35dd98, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &1862938725
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1862938722}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1862938726
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1862938722}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.07, y: 0.07, z: 0.07}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2135367910}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1865083922 --- !u!114 &1865083922
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -29041,7 +29277,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 918186759} - {fileID: 1542244751}
m_Father: {fileID: 771549578} m_Father: {fileID: 771549578}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -30092,6 +30328,12 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 13 m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &2020549004 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2645232028057148461, guid: cf8684b3c4f47b94aa7cb23ce498caf3,
type: 3}
m_PrefabInstance: {fileID: 1774209490}
m_PrefabAsset: {fileID: 0}
--- !u!65 &2020718193 --- !u!65 &2020718193
BoxCollider: BoxCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -31265,7 +31507,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 587127950} - {fileID: 1862938726}
m_Father: {fileID: 771549578} m_Father: {fileID: 771549578}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -33798,7 +34040,7 @@ PrefabInstance:
- target: {fileID: 6563380807134184743, guid: 5da4516f609052242915c455fc208ca2, - target: {fileID: 6563380807134184743, guid: 5da4516f609052242915c455fc208ca2,
type: 3} type: 3}
propertyPath: m_Interactable propertyPath: m_Interactable
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6563380807134184743, guid: 5da4516f609052242915c455fc208ca2, - target: {fileID: 6563380807134184743, guid: 5da4516f609052242915c455fc208ca2,
type: 3} type: 3}
@ -33813,12 +34055,12 @@ PrefabInstance:
- target: {fileID: 6563380807134184743, guid: 5da4516f609052242915c455fc208ca2, - target: {fileID: 6563380807134184743, guid: 5da4516f609052242915c455fc208ca2,
type: 3} type: 3}
propertyPath: m_Options.m_Options.Array.data[2].m_Text propertyPath: m_Options.m_Options.Array.data[2].m_Text
value: Distance value: Distance (WIP)
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6563380807134184743, guid: 5da4516f609052242915c455fc208ca2, - target: {fileID: 6563380807134184743, guid: 5da4516f609052242915c455fc208ca2,
type: 3} type: 3}
propertyPath: m_Options.m_Options.Array.data[3].m_Text propertyPath: m_Options.m_Options.Array.data[3].m_Text
value: Smooth (NOT Recommend) value: Smooth (NOT Recommend) (WIP)
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5da4516f609052242915c455fc208ca2, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 5da4516f609052242915c455fc208ca2, type: 3}

View File

@ -77,7 +77,7 @@ public class Config
Distance = 2, Distance = 2,
Smooth = 3, Smooth = 3,
} }
public float HandStabilVelocity = 0.1f; public float HandStabilVelocity = 0.3f;
public float HandStabilDistance = 0.1f; public float HandStabilDistance = 0.1f;
public float HandStabilSmooth = 0.1f; public float HandStabilSmooth = 0.1f;
public bool useLight = true; public bool useLight = true;

View File

@ -14,8 +14,8 @@ public class PlayerSettingManager : MonoBehaviour
private double lowerLimit = -10; // meters private double lowerLimit = -10; // meters
void Start() void Start()
{ {
LHandTransform = transform.Find("Camera Offset").Find("LeftHand Controller").Find("LHand"); LHandTransform = transform.Find("Camera Offset").Find("LeftHand Controller").Find("LHand Virtual");
RHandTransform = transform.Find("Camera Offset").Find("RightHand Controller").Find("RHand"); RHandTransform = transform.Find("Camera Offset").Find("RightHand Controller").Find("RHand Virtual");
ConfigManager.onConfigChanged += ApplyConfig; ConfigManager.onConfigChanged += ApplyConfig;
ConfigManager.EnsureInitialization(); ConfigManager.EnsureInitialization();
ApplyConfig(); ApplyConfig();

View File

@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HandFollowManager : MonoBehaviour
{
public GameObject Target;
public Transform Center;
public Config.handStabilization Mode;
public float VelocityThreshold = 0.1f;
private Rigidbody TargetRigidbody;
private Vector3 previousPosition;
private void Start()
{
TargetRigidbody = Target.GetComponent<Rigidbody>();
ConfigManager.onConfigChanged += ApplyConfig;
ConfigManager.EnsureInitialization();
ApplyConfig();
}
private void ApplyConfig()
{
VelocityThreshold = ConfigManager.config.HandStabilVelocity;
Mode = ConfigManager.config.HandStabilizationMode;
}
private void VelocityTracking()
{
Vector3 velocity = (Target.transform.position - previousPosition) / Time.deltaTime;
if (velocity.magnitude > VelocityThreshold)
{
transform.position = Target.transform.position;
}
previousPosition = Target.transform.position;
}
private void Update()
{
gameObject.transform.localScale = Target.transform.localScale;
}
private void FixedUpdate()
{
switch (Mode)
{
case Config.handStabilization.Velocity:
VelocityTracking();
break;
case Config.handStabilization.None:
transform.position = Target.transform.position;
break;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 21fbb267de3292549be7c4a22d42cc53
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: