Skip to content

Commit

Permalink
hit with item animation
Browse files Browse the repository at this point in the history
  • Loading branch information
stilnat committed Oct 28, 2024
1 parent 82e0820 commit 8881e86
Show file tree
Hide file tree
Showing 10 changed files with 515 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5322,9 +5322,9 @@ MonoBehaviour:
m_Root: {fileID: 4153415939737701389}
m_Tip: {fileID: 8420821262611087137}
m_Target: {fileID: 4846808082985781182}
m_ChainRotationWeight: 0.802
m_ChainRotationWeight: 1
m_TipRotationWeight: 1
m_MaxIterations: 15
m_MaxIterations: 50
m_Tolerance: 0.0001
m_MaintainTargetPositionOffset: 0
m_MaintainTargetRotationOffset: 0
Expand Down Expand Up @@ -6956,6 +6956,7 @@ GameObject:
- component: {fileID: 7601720951202063522}
- component: {fileID: 8615535220686661918}
- component: {fileID: 3054724180155005980}
- component: {fileID: 1949858558513743142}
m_Layer: 0
m_Name: UberHuman
m_TagString: Untagged
Expand Down Expand Up @@ -7080,11 +7081,11 @@ MonoBehaviour:
- {fileID: 3265741626988572248}
- {fileID: 5257508295790914349}
- {fileID: 909431137198346835}
- {fileID: 0}
- {fileID: 2768583506857238720}
- {fileID: 7601720951202063522}
- {fileID: 8615535220686661918}
- {fileID: 3054724180155005980}
- {fileID: 1949858558513743142}
- {fileID: 3624753817424616501}
- {fileID: 4379150911436436683}
- {fileID: 7933397141592770015}
Expand Down Expand Up @@ -7600,7 +7601,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c820c500b2966a940907fe7f9855c107, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 16
_componentIndexCache: 15
_addedNetworkObject: {fileID: 241836927429143711}
_networkObjectCache: {fileID: 241836927429143711}
_armatureRoot: {fileID: 3362543718434004155}
Expand All @@ -7621,7 +7622,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 524774ef343211042b18bd7442ba4ee5, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 17
_componentIndexCache: 16
_addedNetworkObject: {fileID: 241836927429143711}
_networkObjectCache: {fileID: 241836927429143711}
_ragdoll: {fileID: 2768583506857238720}
Expand All @@ -7638,7 +7639,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7caa3b96ae405e74d9512d65caf2385f, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 18
_componentIndexCache: 17
_addedNetworkObject: {fileID: 241836927429143711}
_networkObjectCache: {fileID: 241836927429143711}
<LookAtTargetLocker>k__BackingField: {fileID: 5358384094254398678}
Expand All @@ -7660,16 +7661,33 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dd3cc10aaeffdd44682180f6eb9bea3f, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 19
_componentIndexCache: 18
_addedNetworkObject: {fileID: 241836927429143711}
_networkObjectCache: {fileID: 241836927429143711}
_hands: {fileID: 3222345056416986628}
_movementController: {fileID: 313020066527916364}
_bodyAimRig: {fileID: 4182499762659887119}
_holdController: {fileID: 5029722283718734781}
<AimTarget>k__BackingField: {fileID: 2856800849451305125}
_isAimingToThrow: 0
_isAimingToShoot: 0
<AimTarget>k__BackingField: {fileID: 2856800849451305125}
--- !u!114 &1949858558513743142
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4089496606853742746}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0f08a3260b736784db0ff14279854a34, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 19
_addedNetworkObject: {fileID: 241836927429143711}
_networkObjectCache: {fileID: 241836927429143711}
_hands: {fileID: 3222345056416986628}
_lookAtConstraint: {fileID: 2851688491558728783}
_lookAtTargetLocker: {fileID: 5358384094254398678}
--- !u!1 &4092542307493577921
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -10144,7 +10162,7 @@ MonoBehaviour:
m_Target: {fileID: 4607633442489985284}
m_ChainRotationWeight: 1
m_TipRotationWeight: 1
m_MaxIterations: 15
m_MaxIterations: 50
m_Tolerance: 0.0001
m_MaintainTargetPositionOffset: 0
m_MaintainTargetRotationOffset: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,37 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &5900002242402729216
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8004082369185482690}
m_Layer: 0
m_Name: HitPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8004082369185482690
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5900002242402729216}
m_LocalRotation: {x: 0.5, y: 0.5, z: -0.5, w: 0.5}
m_LocalPosition: {x: -0.001, y: -0.017, z: -0.003}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2622462038699768903}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 90, y: 90, z: 0}
--- !u!1 &7256796119011547647
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -137,6 +168,7 @@ GameObject:
- component: {fileID: 3030099257807928672}
- component: {fileID: 5880508585891078262}
- component: {fileID: 6087395387405227362}
- component: {fileID: 4719599284485312325}
m_Layer: 0
m_Name: ToolboxBlue
m_TagString: Untagged
Expand All @@ -157,6 +189,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 178022904214631610}
- {fileID: 8004082369185482690}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -291,6 +324,7 @@ MonoBehaviour:
- {fileID: 1709916980240734861}
- {fileID: 774012773725995252}
- {fileID: 3030099257807928672}
- {fileID: 6087395387405227362}
<ParentNetworkObject>k__BackingField: {fileID: 0}
<ChildNetworkObjects>k__BackingField: []
SerializedTransformProperties:
Expand Down Expand Up @@ -442,6 +476,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e2f43d6592863cc4c9dcad00f8a27ce7, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 4
_addedNetworkObject: {fileID: 6822718982116855690}
_networkObjectCache: {fileID: 6822718982116855690}
_primaryRightHandHold: {fileID: 2985470090995767133}
_primaryLeftHandHold: {fileID: 5964965102207218486}
_secondaryRightHandHold: {fileID: 0}
Expand All @@ -455,6 +492,21 @@ MonoBehaviour:
_twoHandHoldThrow: 0
_primaryHandPoseType: 0
_secondaryHandPoseType: 0
--- !u!114 &4719599284485312325
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7256796119011547647}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2106a18e55486ca4c9b0c7e41128f9b5, type: 3}
m_Name:
m_EditorClassIdentifier:
HitPoint: {fileID: 8004082369185482690}
forwardHit: {x: 0, y: 0, z: -1}
upHit: {x: 1, y: 0, z: 0}
--- !u!1 &8783882920935154563
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ GameObject:
- component: {fileID: 2543825028282008237}
- component: {fileID: 7555427621416321058}
- component: {fileID: 7296799606748695713}
- component: {fileID: 8238211886652055266}
m_Layer: 10
m_Name: Wrench
m_TagString: Untagged
Expand All @@ -73,6 +74,7 @@ Transform:
- {fileID: 8876393141157652533}
- {fileID: 4069600695964099484}
- {fileID: 9003863549386358971}
- {fileID: 3424821083880257427}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -218,11 +220,13 @@ MonoBehaviour:
_networkBehaviours:
- {fileID: 2058044439099520297}
- {fileID: 8540712827701727508}
- {fileID: 7555427621416321058}
- {fileID: 7296799606748695713}
<ParentNetworkObject>k__BackingField: {fileID: 0}
<ChildNetworkObjects>k__BackingField: []
SerializedTransformProperties:
Position: {x: 0, y: -0.0002392903, z: 0.0010859836}
Rotation: {x: -0.0046695666, y: -0, z: -0, w: 0.9999891}
Position: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 1}
LocalScale: {x: 1, y: 1, z: 1}
_isNetworked: 1
_isGlobal: 0
Expand Down Expand Up @@ -292,6 +296,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 99df7ac2c21c2d944818b5da5be3dd53, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 2
_addedNetworkObject: {fileID: 4052990814619214022}
_networkObjectCache: {fileID: 4052990814619214022}
_primaryRightHandHold: {fileID: 8876393141157652533}
_primaryLeftHandHold: {fileID: 4069600695964099484}
_secondaryRightHandHold: {fileID: 0}
Expand All @@ -309,7 +316,56 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4108b98460286644380527864e4f8382, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 3
_addedNetworkObject: {fileID: 4052990814619214022}
_networkObjectCache: {fileID: 4052990814619214022}
_interactionPoint: {fileID: 9003863549386358971}
--- !u!114 &8238211886652055266
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3792017003477948967}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2106a18e55486ca4c9b0c7e41128f9b5, type: 3}
m_Name:
m_EditorClassIdentifier:
HitPoint: {fileID: 3424821083880257427}
forwardHit: {x: 0, y: 1, z: 0}
upHit: {x: 0, y: 0, z: -1}
--- !u!1 &7767416049704309750
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3424821083880257427}
m_Layer: 0
m_Name: HitPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3424821083880257427
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7767416049704309750}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.002, y: 0.313, z: -0.007}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 199471781468022836}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7780218464811753928
GameObject:
m_ObjectHideFlags: 0
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/SS3D/Systems/Animations/HitAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ private Tween AnimateHandPosition(Vector3 hitTargetPosition, float duration, Qua
// compute the trajectory deviation point, using the cross product to get a vector orthogonal to the hit direction,
// then, from the middle of the distance between hand and hit, step on the side from a given quantity.
// Uses the up vector for the cross product, hopefully the player never hits perfectly vertically
Vector3 trajectoryPeak = middleFromHandToHit + (deviationRightOrLeft * (Vector3.Cross(Vector3.up, fromHandToHitRelativeToPlayer).normalized * deviationFromStraightTrajectory));
Vector3 trajectoryPeak = middleFromHandToHit + (Vector3.Cross(Vector3.up, fromHandToHitRelativeToPlayer).normalized * (deviationRightOrLeft * deviationFromStraightTrajectory));

// Same as trajectoryPeak but for when the hand gets back in rest position
Vector3 trajectoryPeakBack = middleFromHandToHit - (deviationRightOrLeft * (Vector3.Cross(Vector3.up, fromHandToHitRelativeToPlayer).normalized * deviationFromStraightTrajectory));
Vector3 trajectoryPeakBack = middleFromHandToHit - (Vector3.Cross(Vector3.up, fromHandToHitRelativeToPlayer).normalized * (deviationRightOrLeft * deviationFromStraightTrajectory));

// show the hit target position in the player referential
DebugExtension.DebugPoint((transform.rotation * hitPositionRelativeToPlayer) + transform.position, Color.blue, 0.2f, 2f);
Expand Down
Loading

0 comments on commit 8881e86

Please sign in to comment.