add physics hand
This commit is contained in:
parent
b2c2a8311e
commit
687f2c8ec4
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@ public class Config
|
||||
public float HapticDuration = 0.1f;
|
||||
public float HapticAmplitude = 0.75f;
|
||||
public int TouchSampleRate = 3;
|
||||
public int HandStabilization = 0;
|
||||
public int HandTrackingMode = 0;
|
||||
public float Threshold = 0.3f;
|
||||
public float HandStabilVelocity = 0.3f;
|
||||
public float HandStabilDistance = 0.1f;
|
||||
|
@ -8,14 +8,17 @@ public class HandFollowManager : MonoBehaviour
|
||||
public Transform Center;
|
||||
public CEnum.handStabilization Mode;
|
||||
public float VelocityThreshold = 0.1f;
|
||||
private Rigidbody currentRigidbody;
|
||||
private Rigidbody TargetRigidbody;
|
||||
private Vector3 previousPosition;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
TargetRigidbody = Target.GetComponent<Rigidbody>();
|
||||
currentRigidbody = GetComponent<Rigidbody>();
|
||||
|
||||
var modeWidget = ConfigManager.GetConfigPanelWidget("HandStabilization");
|
||||
var modeWidget = ConfigManager.GetConfigPanelWidget("HandTrackingMode");
|
||||
var threshWidget = ConfigManager.GetConfigPanelWidget("Threshold");
|
||||
|
||||
var modeDropdown = modeWidget.GetComponent<TMP_Dropdown>();
|
||||
@ -24,6 +27,18 @@ public class HandFollowManager : MonoBehaviour
|
||||
modeDropdown.onValueChanged.AddListener((int value) => {
|
||||
VelocityThreshold = ConfigManager.config.HandStabilVelocity;
|
||||
Mode = (CEnum.handStabilization)value;
|
||||
switch (Mode)
|
||||
{
|
||||
case CEnum.handStabilization.None:
|
||||
currentRigidbody.isKinematic = true;
|
||||
break;
|
||||
case CEnum.handStabilization.Physics:
|
||||
currentRigidbody.isKinematic = false;
|
||||
break;
|
||||
case CEnum.handStabilization.Velocity:
|
||||
currentRigidbody.isKinematic = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
threshSlider.onValueChanged.AddListener((float value) => {
|
||||
@ -40,9 +55,21 @@ public class HandFollowManager : MonoBehaviour
|
||||
if (velocity.magnitude > VelocityThreshold)
|
||||
{
|
||||
transform.position = Target.transform.position;
|
||||
//PhysicsMove(Target.transform);
|
||||
}
|
||||
previousPosition = Target.transform.position;
|
||||
}
|
||||
|
||||
private void PhysicsMove(Transform targetTransform)
|
||||
{
|
||||
currentRigidbody.velocity = (targetTransform.position - transform.position) / Time.fixedDeltaTime;
|
||||
|
||||
Quaternion rotationDelta = targetTransform.rotation * Quaternion.Inverse(transform.rotation);
|
||||
rotationDelta.ToAngleAxis(out float angle, out Vector3 axis);
|
||||
|
||||
Vector3 rotationDeltaInDegrees = angle * axis;
|
||||
currentRigidbody.angularVelocity = rotationDeltaInDegrees * Mathf.Deg2Rad / Time.fixedDeltaTime;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
gameObject.transform.localScale = Target.transform.localScale;
|
||||
@ -52,12 +79,16 @@ public class HandFollowManager : MonoBehaviour
|
||||
{
|
||||
switch (Mode)
|
||||
{
|
||||
case CEnum.handStabilization.Velocity:
|
||||
VelocityTracking();
|
||||
break;
|
||||
case CEnum.handStabilization.None:
|
||||
transform.position = Target.transform.position;
|
||||
break;
|
||||
case CEnum.handStabilization.Physics:
|
||||
//transform.position = Target.transform.position;
|
||||
PhysicsMove(Target.transform);
|
||||
break;
|
||||
case CEnum.handStabilization.Velocity:
|
||||
VelocityTracking();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +38,10 @@ public class CEnum
|
||||
public enum handStabilization
|
||||
{
|
||||
None = 0,
|
||||
Velocity = 1,
|
||||
Distance = 2,
|
||||
Smooth = 3,
|
||||
Physics = 1,
|
||||
Velocity = 2,
|
||||
Distance = 3,
|
||||
Smooth = 4,
|
||||
}
|
||||
public enum listType
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ TextureImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
mipMapMode: 1
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
@ -34,7 +34,7 @@ TextureImporter:
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
aniso: 4
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 MiB |
@ -1,123 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f051b96be60b58d4bad870fd6b9d367c
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -18,7 +18,7 @@ PhysicsManager:
|
||||
m_ClothInterCollisionDistance: 0.1
|
||||
m_ClothInterCollisionStiffness: 0.2
|
||||
m_ContactsGeneration: 1
|
||||
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
m_AutoSimulation: 1
|
||||
m_AutoSyncTransforms: 0
|
||||
m_ReuseCollisionCallbacks: 0
|
||||
|
@ -21,7 +21,7 @@ QualitySettings:
|
||||
skinWeights: 2
|
||||
textureQuality: 0
|
||||
anisotropicTextures: 1
|
||||
antiAliasing: 0
|
||||
antiAliasing: 2
|
||||
softParticles: 0
|
||||
softVegetation: 0
|
||||
realtimeReflectionProbes: 1
|
||||
@ -29,7 +29,7 @@ QualitySettings:
|
||||
vSyncCount: 0
|
||||
lodBias: 0.4
|
||||
maximumLODLevel: 0
|
||||
streamingMipmapsActive: 0
|
||||
streamingMipmapsActive: 1
|
||||
streamingMipmapsAddAllCameras: 1
|
||||
streamingMipmapsMemoryBudget: 512
|
||||
streamingMipmapsRenderersPerFrame: 512
|
||||
|
@ -15,8 +15,8 @@ TagManager:
|
||||
- UIText
|
||||
- LIVBlock
|
||||
- LEDs
|
||||
-
|
||||
-
|
||||
- LHandPhysics
|
||||
- RHandPhysics
|
||||
-
|
||||
-
|
||||
-
|
||||
|
Loading…
Reference in New Issue
Block a user