From 88fc896426616a170d94221007737442594b2123 Mon Sep 17 00:00:00 2001 From: aarthificial Date: Tue, 26 Sep 2023 05:47:09 +0200 Subject: [PATCH] refactor: improve footstep events --- Assets/Player/Models/LT.fbx.meta | 6 +- Assets/Player/Models/LT@WalkInPlace.fbx | 3 + Assets/Player/Models/LT@WalkInPlace.fbx.meta | 459 ++++++++++++++++++ .../Player/Models/PlayerAnimator.controller | 8 +- Assets/Player/PlayerController.cs | 2 +- 5 files changed, 472 insertions(+), 6 deletions(-) create mode 100644 Assets/Player/Models/LT@WalkInPlace.fbx create mode 100644 Assets/Player/Models/LT@WalkInPlace.fbx.meta diff --git a/Assets/Player/Models/LT.fbx.meta b/Assets/Player/Models/LT.fbx.meta index cea4a9d..691b56b 100644 --- a/Assets/Player/Models/LT.fbx.meta +++ b/Assets/Player/Models/LT.fbx.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: be89c53bb71f6cd43980c24b02d760e0 ModelImporter: - serializedVersion: 21300 + serializedVersion: 22200 internalIDToNameTable: [] externalObjects: - first: @@ -45,6 +45,7 @@ ModelImporter: addColliders: 0 useSRGBMaterialColor: 1 sortHierarchyByName: 1 + importPhysicalCameras: 1 importVisibility: 1 importBlendShapes: 1 importCameras: 1 @@ -72,6 +73,7 @@ ModelImporter: secondaryUVMinObjectScale: 1 secondaryUVPackMargin: 4 useFileScale: 1 + strictVertexDataChecks: 0 tangentSpace: normalSmoothAngle: 60 normalImportMode: 0 @@ -84,6 +86,7 @@ ModelImporter: - 0b87f89d01130104cb97229365e5a116 - c1e99521b3d54064b947d5fbc8e0a009 - 6ded57c9e8d0d324bb4341d76a1802df + - abc2ac7d55abd2a42a25a5e0c39de361 importAnimation: 0 humanDescription: serializedVersion: 3 @@ -413,6 +416,7 @@ ModelImporter: humanoidOversampling: 1 avatarSetup: 1 addHumanoidExtraRootOnlyWhenUsingAvatar: 1 + importBlendShapeDeformPercent: 0 remapMaterialsIfMaterialImportModeIsNone: 0 additionalBone: 0 userData: diff --git a/Assets/Player/Models/LT@WalkInPlace.fbx b/Assets/Player/Models/LT@WalkInPlace.fbx new file mode 100644 index 0000000..5aa692a --- /dev/null +++ b/Assets/Player/Models/LT@WalkInPlace.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3a539f2c619a6348dacb58e4d8c26774a8ae495a08a6642b184fe4def38dc59 +size 555552 diff --git a/Assets/Player/Models/LT@WalkInPlace.fbx.meta b/Assets/Player/Models/LT@WalkInPlace.fbx.meta new file mode 100644 index 0000000..be549ef --- /dev/null +++ b/Assets/Player/Models/LT@WalkInPlace.fbx.meta @@ -0,0 +1,459 @@ +fileFormatVersion: 2 +guid: abc2ac7d55abd2a42a25a5e0c39de361 +ModelImporter: + serializedVersion: 22200 + internalIDToNameTable: [] + externalObjects: {} + materials: + materialImportMode: 2 + materialName: 0 + materialSearch: 1 + materialLocation: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + removeConstantScaleCurves: 1 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 + animationCompression: 3 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + extraUserProperties: [] + clipAnimations: + - serializedVersion: 16 + name: Idle + takeName: mixamo.com + internalID: -203655887218126122 + firstFrame: 0 + lastFrame: 62 + wrapMode: 0 + orientationOffsetY: 0 + level: 0 + cycleOffset: 0 + loop: 0 + hasAdditiveReferencePose: 0 + loopTime: 1 + loopBlend: 1 + loopBlendOrientation: 1 + loopBlendPositionY: 1 + loopBlendPositionXZ: 1 + keepOriginalOrientation: 0 + keepOriginalPositionY: 1 + keepOriginalPositionXZ: 1 + heightFromFeet: 0 + mirror: 0 + bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 + curves: [] + events: + - time: 0.2800000 + functionName: OnPlayerStep + data: + objectReferenceParameter: {instanceID: 0} + floatParameter: 0 + intParameter: 0 + messageOptions: 0 + - time: 0.7800000 + functionName: OnPlayerStep + data: + objectReferenceParameter: {instanceID: 0} + floatParameter: 0 + intParameter: 0 + messageOptions: 0 + transformMask: [] + maskType: 3 + maskSource: {instanceID: 0} + additiveReferencePoseFrame: 0 + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + useSRGBMaterialColor: 1 + sortHierarchyByName: 1 + importPhysicalCameras: 1 + importVisibility: 1 + importBlendShapes: 1 + importCameras: 1 + importLights: 1 + nodeNameCollisionStrategy: 1 + fileIdsGeneration: 2 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + keepQuads: 0 + weldVertices: 1 + bakeAxisConversion: 0 + preserveHierarchy: 0 + skinWeightsMode: 0 + maxBonesPerVertex: 4 + minBoneWeight: 0.001 + optimizeBones: 1 + meshOptimizationFlags: -1 + indexFormat: 0 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVMarginMethod: 1 + secondaryUVMinLightmapResolution: 40 + secondaryUVMinObjectScale: 1 + secondaryUVPackMargin: 4 + useFileScale: 1 + strictVertexDataChecks: 0 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + normalCalculationMode: 4 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 + referencedClips: [] + importAnimation: 1 + humanDescription: + serializedVersion: 3 + human: + - boneName: Hips + humanName: Hips + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: UpperLeg.L + humanName: LeftUpperLeg + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: UpperLeg.R + humanName: RightUpperLeg + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: LowerLeg.L + humanName: LeftLowerLeg + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: LowerLeg.R + humanName: RightLowerLeg + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Foot.L + humanName: LeftFoot + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Foot.R + humanName: RightFoot + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Spine + humanName: Spine + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Chest + humanName: Chest + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Neck + humanName: Neck + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Head + humanName: Head + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Shoulder.L + humanName: LeftShoulder + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Shoulder.R + humanName: RightShoulder + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: UpperArm.L + humanName: LeftUpperArm + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: UpperArm.R + humanName: RightUpperArm + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: LowerArm.L + humanName: LeftLowerArm + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: LowerArm.R + humanName: RightLowerArm + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Hand.L + humanName: LeftHand + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Hand.R + humanName: RightHand + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Toes.L + humanName: LeftToes + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: Toes.R + humanName: RightToes + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + - boneName: UpperChest + humanName: UpperChest + limit: + min: {x: 0, y: 0, z: 0} + max: {x: 0, y: 0, z: 0} + value: {x: 0, y: 0, z: 0} + length: 0 + modified: 0 + skeleton: + - name: LT(Clone) + parentName: + position: {x: 0, y: 0, z: 0} + rotation: {x: 0, y: 0, z: 0, w: 1} + scale: {x: 1, y: 1, z: 1} + - name: body + parentName: LT(Clone) + position: {x: -0, y: 0, z: 0} + rotation: {x: -6.123234e-17, y: 1, z: 6.123234e-17, w: -3.7493994e-33} + scale: {x: 1, y: 1, z: 1} + - name: Armature + parentName: LT(Clone) + position: {x: -0, y: 0, z: 0} + rotation: {x: -0.7071067, y: 5.302452e-33, z: 5.302451e-33, w: 0.7071068} + scale: {x: 100, y: 100, z: 100} + - name: Root + parentName: Armature + position: {x: -0, y: 0, z: 0} + rotation: {x: 0, y: 0, z: 1, w: -6.123234e-17} + scale: {x: 1, y: 1, z: 1} + - name: Hips + parentName: Root + position: {x: -4.4912407e-19, y: 0.0006554484, z: 0.010067848} + rotation: {x: -0.000000032048426, y: 0.735689, z: 0.6773195, w: -0.000000029505706} + scale: {x: 1, y: 0.99999976, z: 0.99999994} + - name: UpperLeg.L + parentName: Hips + position: {x: -0.0011306495, y: -0.0005676224, z: -0.0000044065864} + rotation: {x: -0.00000055540295, y: -0.038027834, z: 0.9992767, w: 0.00000011211838} + scale: {x: 1, y: 1.0000004, z: 1.0000083} + - name: LowerLeg.L + parentName: UpperLeg.L + position: {x: -5.676796e-11, y: 0.003799503, z: 4.4771936e-11} + rotation: {x: 0.031424515, y: -0.0000003137836, z: 0.00000002542652, w: 0.9995061} + scale: {x: 1, y: 1, z: 1} + - name: Foot.L + parentName: LowerLeg.L + position: {x: -2.1199336e-11, y: 0.004604661, z: 1.18728135e-11} + rotation: {x: 0.53555626, y: -3.3476364e-12, z: 0.00000020855563, w: 0.8444996} + scale: {x: 1, y: 0.99999994, z: 1} + - name: Toes.L + parentName: Foot.L + position: {x: -6.22333e-11, y: 0.0017427616, z: -7.797332e-11} + rotation: {x: 0.26492408, y: 0.000000042149374, z: 0.00000011474552, w: 0.9642693} + scale: {x: 1, y: 0.99999994, z: 0.9999999} + - name: Spine + parentName: Hips + position: {x: 4.890016e-18, y: 0.001430476, z: -1.0244548e-10} + rotation: {x: -0.084649414, y: -0.00000004355449, z: -0.0000000037001413, w: 0.9964108} + scale: {x: 1, y: 1, z: 1} + - name: Chest + parentName: Spine + position: {x: -1.0587912e-24, y: 0.0022081889, z: 7.4505804e-11} + rotation: {x: -0.1593642, y: -0.00000011768577, z: 0.000000018997692, w: 0.98721987} + scale: {x: 1, y: 1, z: 1} + - name: UpperChest + parentName: Chest + position: {x: -1.000329e-16, y: 0.002074371, z: -4.0978193e-10} + rotation: {x: 0.12718073, y: 5.2887246e-15, z: -0.000000030322248, w: 0.9918796} + scale: {x: 1, y: 1, z: 1} + - name: Shoulder.L + parentName: UpperChest + position: {x: -0.00074966985, y: 0.00050478225, z: -0.00012990698} + rotation: {x: 0.04845659, y: -0.058435958, z: 0.767554, w: 0.6364732} + scale: {x: 1, y: 1, z: 0.99999994} + - name: UpperArm.L + parentName: Shoulder.L + position: {x: 0.0000000011684704, y: 0.0021134785, z: -5.337637e-12} + rotation: {x: -0.0017008409, y: -0.009929072, z: -0.07304767, w: 0.9972776} + scale: {x: 0.99999994, y: 1.0000001, z: 1} + - name: LowerArm.L + parentName: UpperArm.L + position: {x: 4.8621586e-11, y: 0.002920631, z: -1.8626451e-11} + rotation: {x: 0.04200489, y: -0.00027804353, z: -0.020369206, w: 0.9989098} + scale: {x: 1, y: 1.0000001, z: 1} + - name: Hand.L + parentName: LowerArm.L + position: {x: 5.9608284e-11, y: 0.002781662, z: -3.7252902e-11} + rotation: {x: 0.0180567, y: -0.0038402092, z: -0.060190707, w: 0.9980162} + scale: {x: 0.99999994, y: 1, z: 0.9999998} + - name: Neck + parentName: UpperChest + position: {x: 1.5430295e-17, y: 0.0015972919, z: 7.4505804e-11} + rotation: {x: 0.12637079, y: 1.2578757e-14, z: -0.000000030129144, w: 0.9919831} + scale: {x: 1, y: 1, z: 1} + - name: Head + parentName: Neck + position: {x: 6.548511e-18, y: 0.0011938551, z: 1.4901161e-10} + rotation: {x: -0.049391046, y: -6.551487e-15, z: 0.000000011775741, w: 0.99877954} + scale: {x: 1, y: 1, z: 1} + - name: Shoulder.R + parentName: UpperChest + position: {x: 0.00074966974, y: 0.00050478225, z: -0.00012990735} + rotation: {x: 0.048456404, y: 0.058436103, z: -0.767554, w: 0.6364732} + scale: {x: 1, y: 1, z: 0.99999994} + - name: UpperArm.R + parentName: Shoulder.R + position: {x: -0.0000000010863782, y: 0.002113479, z: -3.1825008e-11} + rotation: {x: -0.0017009561, y: 0.009928896, z: 0.07304749, w: 0.9972776} + scale: {x: 0.9999999, y: 1.0000001, z: 1} + - name: LowerArm.R + parentName: UpperArm.R + position: {x: -3.4247477e-10, y: 0.0029206318, z: -1.8626451e-11} + rotation: {x: 0.042005178, y: 0.00027798204, z: 0.020369077, w: 0.9989097} + scale: {x: 1, y: 1, z: 1} + - name: Hand.R + parentName: LowerArm.R + position: {x: 8.3526175e-10, y: 0.0027816617, z: 5.5879353e-11} + rotation: {x: 0.018056706, y: 0.0038402076, z: 0.060190704, w: 0.9980162} + scale: {x: 1, y: 1, z: 0.9999998} + - name: UpperLeg.R + parentName: Hips + position: {x: 0.0011306495, y: -0.0005676224, z: -0.000004406463} + rotation: {x: 0.0000004366244, y: -0.038027838, z: 0.9992767, w: -0.00000011663854} + scale: {x: 1, y: 1.0000004, z: 1.0000082} + - name: LowerLeg.R + parentName: UpperLeg.R + position: {x: -1.1425998e-10, y: 0.0037995037, z: -2.5349606e-11} + rotation: {x: 0.03142453, y: 0.0000002819687, z: -0.00000001777879, w: 0.9995061} + scale: {x: 1, y: 1, z: 1} + - name: Foot.R + parentName: LowerLeg.R + position: {x: -5.330633e-11, y: 0.0046046604, z: -6.7526783e-12} + rotation: {x: 0.53555626, y: 3.1465566e-12, z: -0.0000002085555, w: 0.8444996} + scale: {x: 1, y: 0.9999999, z: 1} + - name: Toes.R + parentName: Foot.R + position: {x: 6.223318e-11, y: 0.0017427617, z: -7.79729e-11} + rotation: {x: 0.26492405, y: -0.000000042149402, z: -0.00000011474549, w: 0.9642693} + scale: {x: 1, y: 0.9999999, z: 1} + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + globalScale: 1 + rootMotionBoneName: + hasTranslationDoF: 0 + hasExtraRoot: 1 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {fileID: 9000000, guid: be89c53bb71f6cd43980c24b02d760e0, + type: 3} + autoGenerateAvatarMappingIfUnspecified: 1 + animationType: 3 + humanoidOversampling: 1 + avatarSetup: 2 + addHumanoidExtraRootOnlyWhenUsingAvatar: 1 + importBlendShapeDeformPercent: 0 + remapMaterialsIfMaterialImportModeIsNone: 0 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Player/Models/PlayerAnimator.controller b/Assets/Player/Models/PlayerAnimator.controller index 9d87dbe..9134962 100644 --- a/Assets/Player/Models/PlayerAnimator.controller +++ b/Assets/Player/Models/PlayerAnimator.controller @@ -14,7 +14,7 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -126,7 +126,7 @@ AnimatorStateTransition: m_Conditions: - m_ConditionMode: 3 m_ConditionEvent: speed - m_EventTreshold: 0.01 + m_EventTreshold: 0.1 m_DstStateMachine: {fileID: 0} m_DstState: {fileID: 119421756791919613} m_Solo: 0 @@ -176,7 +176,7 @@ AnimatorStateTransition: m_Conditions: - m_ConditionMode: 4 m_ConditionEvent: speed - m_EventTreshold: 0.01 + m_EventTreshold: 0.1 m_DstStateMachine: {fileID: 0} m_DstState: {fileID: 1552177660250630025} m_Solo: 0 @@ -200,7 +200,7 @@ BlendTree: m_Name: Blend Tree m_Childs: - serializedVersion: 2 - m_Motion: {fileID: -203655887218126122, guid: 0b87f89d01130104cb97229365e5a116, + m_Motion: {fileID: -203655887218126122, guid: abc2ac7d55abd2a42a25a5e0c39de361, type: 3} m_Threshold: 0 m_Position: {x: 0, y: 0} diff --git a/Assets/Player/PlayerController.cs b/Assets/Player/PlayerController.cs index 5653d90..42316be 100644 --- a/Assets/Player/PlayerController.cs +++ b/Assets/Player/PlayerController.cs @@ -111,7 +111,7 @@ private void HandleStepped() { return; } if (Physics.Raycast( - transform.position, + transform.position + transform.forward * 0.4f, Vector3.down, out var hit, 2f,