From e269c0920a59ee0e1821bc40f64bc217e40f3281 Mon Sep 17 00:00:00 2001 From: kimrdd Date: Sun, 4 Feb 2024 05:05:52 +0100 Subject: [PATCH 1/2] try runble --- Assets/Scripts/Controller/PS5Controller.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/Controller/PS5Controller.cs b/Assets/Scripts/Controller/PS5Controller.cs index 19d3d5e..d94ad6e 100644 --- a/Assets/Scripts/Controller/PS5Controller.cs +++ b/Assets/Scripts/Controller/PS5Controller.cs @@ -17,6 +17,6 @@ public class PS5Controller : MonoBehaviour // Update is called once per frame void Update() { - + Gamepad.all[0].SetMotorSpeeds(100, 100); } } From d2830b8e596756c5646fcba67ca822817a5a75b8 Mon Sep 17 00:00:00 2001 From: Sveske Juice Date: Sat, 3 Feb 2024 20:40:23 -0800 Subject: [PATCH 2/2] rope pull animation --- .../Player1/PlayerAnimations1.controller | 195 ++++++------------ .../PlayerAnimations/Player1/Swing/Swing.anim | 53 +++-- .../PlayerAnimations/Player2/Idle/Idle.anim | 51 ++++- .../Player2/PlayerAnimations2.controller | 75 +++---- .../Player2/Running/Running.anim | 2 +- .../PlayerAnimations/Player2/Swing/Swing.anim | 120 +++++++++-- Assets/Resources/Player1.prefab | 34 +++ Assets/Resources/Player2.prefab | 36 +++- Assets/Scenes/GameScene.unity | 74 +------ .../Scripts/Player/PlayerAnimationHandler.cs | 6 +- Assets/Scripts/Player/RopeWhipAttack.cs | 32 +++ .../Scripts/Player/SpriteMovementFlipper.cs | 14 +- 12 files changed, 402 insertions(+), 290 deletions(-) diff --git a/Assets/Animations/PlayerAnimations/Player1/PlayerAnimations1.controller b/Assets/Animations/PlayerAnimations/Player1/PlayerAnimations1.controller index 08c43f1..e8bf16f 100644 --- a/Assets/Animations/PlayerAnimations/Player1/PlayerAnimations1.controller +++ b/Assets/Animations/PlayerAnimations/Player1/PlayerAnimations1.controller @@ -1,56 +1,5 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!1102 &-8349034508235637004 -AnimatorState: - serializedVersion: 6 - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Swing - m_Speed: 1 - m_CycleOffset: 0 - m_Transitions: [] - 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: 627150c151bf3fa40b70f232e0aa7f7a, type: 2} - m_Tag: - m_SpeedParameter: - m_MirrorParameter: - m_CycleOffsetParameter: - m_TimeParameter: ---- !u!1101 &-6173615721886091892 -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: Idle - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 9123080415032741332} - 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 --- !u!1107 &-4590016191452643091 AnimatorStateMachine: serializedVersion: 6 @@ -68,29 +17,51 @@ AnimatorStateMachine: m_Position: {x: 470, y: 80, z: 0} - serializedVersion: 1 m_State: {fileID: 5718945116413065706} - m_Position: {x: 360, y: 220, z: 0} - - serializedVersion: 1 - m_State: {fileID: -8349034508235637004} - m_Position: {x: 400, y: 10, z: 0} + m_Position: {x: 130, y: 110, z: 0} - serializedVersion: 1 m_State: {fileID: 3308394434488297487} m_Position: {x: 420, y: 140, z: 0} + - serializedVersion: 1 + m_State: {fileID: -4512082985165587279} + m_Position: {x: 130, y: -20, z: 0} m_ChildStateMachines: [] - m_AnyStateTransitions: - - {fileID: -6173615721886091892} - - {fileID: 5712453572289168545} - - {fileID: -2232175589853228148} - - {fileID: 4210568570521344070} - - {fileID: -2601431713474190462} + m_AnyStateTransitions: [] m_EntryTransitions: [] m_StateMachineTransitions: {} m_StateMachineBehaviours: [] - m_AnyStatePosition: {x: 170, y: 80, z: 0} + m_AnyStatePosition: {x: -180, y: -80, z: 0} m_EntryPosition: {x: -160, y: 180, z: 0} m_ExitPosition: {x: 800, y: 120, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_DefaultState: {fileID: 9123080415032741332} ---- !u!1101 &-2601431713474190462 +--- !u!1102 &-4512082985165587279 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Swing + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: + - {fileID: 4529714568082305897} + 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: 627150c151bf3fa40b70f232e0aa7f7a, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1101 &-2150761196750939476 AnimatorStateTransition: m_ObjectHideFlags: 1 m_CorrespondingSourceObject: {fileID: 0} @@ -98,44 +69,19 @@ AnimatorStateTransition: m_PrefabAsset: {fileID: 0} m_Name: m_Conditions: - - m_ConditionMode: 1 - m_ConditionEvent: Run + - m_ConditionMode: 2 + m_ConditionEvent: IsRunning m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 5718945116413065706} + m_DstState: {fileID: 9123080415032741332} 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 ---- !u!1101 &-2232175589853228148 -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: Mop - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 548892628922324246} - 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_ExitTime: 0.516129 + m_HasExitTime: 1 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 @@ -149,42 +95,18 @@ AnimatorController: m_Name: PlayerAnimations1 serializedVersion: 5 m_AnimatorParameters: - - m_Name: Idle - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - - m_Name: Run - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - - m_Name: Mop - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - - m_Name: RunMop - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - - m_Name: Swing - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - m_Name: IsRunning m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} + - m_Name: IsSwinging + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -250,7 +172,7 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: ---- !u!1101 &4210568570521344070 +--- !u!1101 &4529714568082305897 AnimatorStateTransition: m_ObjectHideFlags: 1 m_CorrespondingSourceObject: {fileID: 0} @@ -258,24 +180,24 @@ AnimatorStateTransition: m_PrefabAsset: {fileID: 0} m_Name: m_Conditions: - - m_ConditionMode: 1 - m_ConditionEvent: RunMop + - m_ConditionMode: 2 + m_ConditionEvent: IsSwinging m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 3308394434488297487} + m_DstState: {fileID: 9123080415032741332} m_Solo: 0 m_Mute: 0 m_IsExit: 0 serializedVersion: 3 m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.75 + m_ExitTime: 0 m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 ---- !u!1101 &5712453572289168545 +--- !u!1101 &5149346213670764323 AnimatorStateTransition: m_ObjectHideFlags: 1 m_CorrespondingSourceObject: {fileID: 0} @@ -284,17 +206,20 @@ AnimatorStateTransition: m_Name: m_Conditions: - m_ConditionMode: 1 - m_ConditionEvent: Swing + m_ConditionEvent: IsRunning + m_EventTreshold: 0 + - m_ConditionMode: 2 + m_ConditionEvent: IsSwinging m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: -8349034508235637004} + m_DstState: {fileID: 5718945116413065706} m_Solo: 0 m_Mute: 0 m_IsExit: 0 serializedVersion: 3 m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.75 + m_ExitTime: 0 m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 @@ -310,7 +235,8 @@ AnimatorState: m_Name: Running m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: -2150761196750939476} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -336,7 +262,8 @@ AnimatorState: m_Name: Idle m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: 5149346213670764323} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 diff --git a/Assets/Animations/PlayerAnimations/Player1/Swing/Swing.anim b/Assets/Animations/PlayerAnimations/Player1/Swing/Swing.anim index 3e63c65..cf181f4 100644 --- a/Assets/Animations/PlayerAnimations/Player1/Swing/Swing.anim +++ b/Assets/Animations/PlayerAnimations/Player1/Swing/Swing.anim @@ -31,7 +31,7 @@ AnimationClip: inWeight: 0 outWeight: 0 - serializedVersion: 3 - time: 0.85 + time: 0.5 value: 1 inSlope: Infinity outSlope: Infinity @@ -39,6 +39,15 @@ AnimationClip: weightedMode: 0 inWeight: 0 outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 @@ -52,20 +61,18 @@ AnimationClip: curve: - time: 0 value: {fileID: 21300000, guid: 240c3a2ef21982f4590d6cd434d91f27, type: 3} - - time: 0.11666667 - value: {fileID: 21300000, guid: 0bac1dfd4dd5df344ade6d0dfc5aa77f, type: 3} - - time: 0.25 + - time: 0.16666667 value: {fileID: 21300000, guid: 2f7b336ea4b22104b831a5aa4ce63e65, type: 3} - - time: 0.36666667 - value: {fileID: 21300000, guid: db90fe6a45c83a74b88da01e595e40ed, type: 3} - - time: 0.48333332 + - time: 0.33333334 value: {fileID: 21300000, guid: d8c1ff9b90b62814bbb6894bfcf4b2bb, type: 3} - - time: 0.6 - value: {fileID: 21300000, guid: de98b85f0c0593e4389e93a6542ba161, type: 3} - - time: 0.73333335 + - time: 0.5 value: {fileID: 21300000, guid: b9a4237d2fdcb3044a222171250fa5fc, type: 3} - - time: 0.85 - value: {fileID: 21300000, guid: 670971dc022801d4aa435f32749cdf05, type: 3} + - time: 0.6666667 + value: {fileID: 21300000, guid: b9a4237d2fdcb3044a222171250fa5fc, type: 3} + - time: 0.8333333 + value: {fileID: 21300000, guid: d8c1ff9b90b62814bbb6894bfcf4b2bb, type: 3} + - time: 1 + value: {fileID: 21300000, guid: 240c3a2ef21982f4590d6cd434d91f27, type: 3} attribute: m_Sprite path: classID: 212 @@ -98,24 +105,23 @@ AnimationClip: isSerializeReferenceCurve: 0 pptrCurveMapping: - {fileID: 21300000, guid: 240c3a2ef21982f4590d6cd434d91f27, type: 3} - - {fileID: 21300000, guid: 0bac1dfd4dd5df344ade6d0dfc5aa77f, type: 3} - {fileID: 21300000, guid: 2f7b336ea4b22104b831a5aa4ce63e65, type: 3} - - {fileID: 21300000, guid: db90fe6a45c83a74b88da01e595e40ed, type: 3} - {fileID: 21300000, guid: d8c1ff9b90b62814bbb6894bfcf4b2bb, type: 3} - - {fileID: 21300000, guid: de98b85f0c0593e4389e93a6542ba161, type: 3} - {fileID: 21300000, guid: b9a4237d2fdcb3044a222171250fa5fc, type: 3} - - {fileID: 21300000, guid: 670971dc022801d4aa435f32749cdf05, type: 3} + - {fileID: 21300000, guid: b9a4237d2fdcb3044a222171250fa5fc, type: 3} + - {fileID: 21300000, guid: d8c1ff9b90b62814bbb6894bfcf4b2bb, type: 3} + - {fileID: 21300000, guid: 240c3a2ef21982f4590d6cd434d91f27, type: 3} m_AnimationClipSettings: serializedVersion: 2 m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 0.8666667 + m_StopTime: 1.0166667 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 1 + m_LoopTime: 0 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 @@ -140,7 +146,7 @@ AnimationClip: inWeight: 0 outWeight: 0 - serializedVersion: 3 - time: 0.85 + time: 0.5 value: 1 inSlope: Infinity outSlope: Infinity @@ -148,6 +154,15 @@ AnimationClip: weightedMode: 0 inWeight: 0 outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 diff --git a/Assets/Animations/PlayerAnimations/Player2/Idle/Idle.anim b/Assets/Animations/PlayerAnimations/Player2/Idle/Idle.anim index f444aeb..042ce95 100644 --- a/Assets/Animations/PlayerAnimations/Player2/Idle/Idle.anim +++ b/Assets/Animations/PlayerAnimations/Player2/Idle/Idle.anim @@ -17,21 +17,64 @@ AnimationClip: m_PositionCurves: [] m_ScaleCurves: [] m_FloatCurves: [] - m_PPtrCurves: [] + m_PPtrCurves: + - serializedVersion: 2 + curve: + - time: 0 + value: {fileID: 21300000, guid: 718f5294a4376b64cb1b4cb93b2b1ea1, type: 3} + - time: 0.083333336 + value: {fileID: 21300000, guid: 927cd4e90ba89684f84229f89f220660, type: 3} + - time: 0.16666667 + value: {fileID: 21300000, guid: a625fc2e591f7094da80bdc3fd188d06, type: 3} + - time: 0.25 + value: {fileID: 21300000, guid: eb7c2944822958b4fa3ad0023fd8164a, type: 3} + - time: 0.33333334 + value: {fileID: 21300000, guid: 98f2e9a668168094bbfdbe8ba57620a8, type: 3} + - time: 0.4 + value: {fileID: 21300000, guid: 2e7e60ee50a68f94c94136dbe15a0447, type: 3} + - time: 0.48333332 + value: {fileID: 21300000, guid: b8376989601bc5e44af322802fef6db9, type: 3} + - time: 0.56666666 + value: {fileID: 21300000, guid: 897ff56abdcb11a46844ac4f9cf6e86a, type: 3} + - time: 0.65 + value: {fileID: 21300000, guid: a199fca6ae9a9d04bb5b55861ba9cc93, type: 3} + attribute: m_Sprite + path: + classID: 212 + script: {fileID: 0} + flags: 2 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: [] - pptrCurveMapping: [] + genericBindings: + - serializedVersion: 2 + path: 0 + attribute: 0 + script: {fileID: 0} + typeID: 212 + customType: 23 + isPPtrCurve: 1 + isIntCurve: 0 + isSerializeReferenceCurve: 0 + pptrCurveMapping: + - {fileID: 21300000, guid: 718f5294a4376b64cb1b4cb93b2b1ea1, type: 3} + - {fileID: 21300000, guid: 927cd4e90ba89684f84229f89f220660, type: 3} + - {fileID: 21300000, guid: a625fc2e591f7094da80bdc3fd188d06, type: 3} + - {fileID: 21300000, guid: eb7c2944822958b4fa3ad0023fd8164a, type: 3} + - {fileID: 21300000, guid: 98f2e9a668168094bbfdbe8ba57620a8, type: 3} + - {fileID: 21300000, guid: 2e7e60ee50a68f94c94136dbe15a0447, type: 3} + - {fileID: 21300000, guid: b8376989601bc5e44af322802fef6db9, type: 3} + - {fileID: 21300000, guid: 897ff56abdcb11a46844ac4f9cf6e86a, type: 3} + - {fileID: 21300000, guid: a199fca6ae9a9d04bb5b55861ba9cc93, type: 3} m_AnimationClipSettings: serializedVersion: 2 m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 1 + m_StopTime: 0.6666666 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 diff --git a/Assets/Animations/PlayerAnimations/Player2/PlayerAnimations2.controller b/Assets/Animations/PlayerAnimations/Player2/PlayerAnimations2.controller index 053efc1..997c446 100644 --- a/Assets/Animations/PlayerAnimations/Player2/PlayerAnimations2.controller +++ b/Assets/Animations/PlayerAnimations/Player2/PlayerAnimations2.controller @@ -11,15 +11,43 @@ AnimatorStateTransition: - m_ConditionMode: 1 m_ConditionEvent: IsRunning m_EventTreshold: 0 + - m_ConditionMode: 2 + m_ConditionEvent: IsSwinging + m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} m_DstState: {fileID: 8304111510876962717} m_Solo: 0 m_Mute: 0 m_IsExit: 0 serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &-5519219387846060971 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 2 + m_ConditionEvent: IsSwinging + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 3357306648811348641} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.75 + m_ExitTime: 0.516129 m_HasExitTime: 1 m_HasFixedDuration: 1 m_InterruptionSource: 0 @@ -39,7 +67,7 @@ AnimatorStateMachine: m_Position: {x: 20, y: -30, z: 0} - serializedVersion: 1 m_State: {fileID: -944807189804630194} - m_Position: {x: 530, y: 80, z: 0} + m_Position: {x: 270, y: -100, z: 0} - serializedVersion: 1 m_State: {fileID: 3748437463534410733} m_Position: {x: 530, y: 170, z: 0} @@ -78,9 +106,9 @@ AnimatorStateTransition: serializedVersion: 3 m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.516129 + m_ExitTime: 0 m_HasExitTime: 1 - m_HasFixedDuration: 1 + m_HasFixedDuration: 0 m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 @@ -94,7 +122,8 @@ AnimatorState: m_Name: Swing m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: -5519219387846060971} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -119,42 +148,18 @@ AnimatorController: m_Name: PlayerAnimations2 serializedVersion: 5 m_AnimatorParameters: - - m_Name: Idle - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - - m_Name: Run - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - - m_Name: Mop - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - - m_Name: Swing - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - - m_Name: RunMop - m_Type: 9 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - m_Name: IsRunning m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} + - m_Name: IsSwinging + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer diff --git a/Assets/Animations/PlayerAnimations/Player2/Running/Running.anim b/Assets/Animations/PlayerAnimations/Player2/Running/Running.anim index 85a83fe..b5bf4de 100644 --- a/Assets/Animations/PlayerAnimations/Player2/Running/Running.anim +++ b/Assets/Animations/PlayerAnimations/Player2/Running/Running.anim @@ -82,7 +82,7 @@ AnimationClip: m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 0 + m_LoopTime: 1 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 diff --git a/Assets/Animations/PlayerAnimations/Player2/Swing/Swing.anim b/Assets/Animations/PlayerAnimations/Player2/Swing/Swing.anim index cb510f2..59d0c7b 100644 --- a/Assets/Animations/PlayerAnimations/Player2/Swing/Swing.anim +++ b/Assets/Animations/PlayerAnimations/Player2/Swing/Swing.anim @@ -16,26 +16,63 @@ AnimationClip: m_EulerCurves: [] m_PositionCurves: [] m_ScaleCurves: [] - m_FloatCurves: [] + m_FloatCurves: + - serializedVersion: 2 + curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 0.5 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_FlipX + path: + classID: 212 + script: {fileID: 0} + flags: 0 m_PPtrCurves: - serializedVersion: 2 curve: - time: 0 value: {fileID: 21300000, guid: eae7bedc4ba0bb44da9664f6f2ae65b0, type: 3} - - time: 0.06666667 - value: {fileID: 21300000, guid: a37285ebdc2fd7e419c0bfe4733bc263, type: 3} - - time: 0.15 + - time: 0.16666667 value: {fileID: 21300000, guid: 6c5d88e222f01644c974b1fe56678bc4, type: 3} - - time: 0.21666667 - value: {fileID: 21300000, guid: d84da234fa9972e44a5a5af15235039d, type: 3} - - time: 0.28333333 - value: {fileID: 21300000, guid: 497fefedd06d8be4585f1a3cd1eeeb3f, type: 3} - - time: 0.35 + - time: 0.33333334 value: {fileID: 21300000, guid: 61363c0901fc4ea469121a6c5e829f24, type: 3} - - time: 0.43333334 - value: {fileID: 21300000, guid: 587fa26a589bca040b756dae3592887a, type: 3} - time: 0.5 value: {fileID: 21300000, guid: d011fbed2a802ed4c87033485707790d, type: 3} + - time: 0.6666667 + value: {fileID: 21300000, guid: 587fa26a589bca040b756dae3592887a, type: 3} + - time: 0.8333333 + value: {fileID: 21300000, guid: a37285ebdc2fd7e419c0bfe4733bc263, type: 3} + - time: 1 + value: {fileID: 21300000, guid: 497fefedd06d8be4585f1a3cd1eeeb3f, type: 3} attribute: m_Sprite path: classID: 212 @@ -48,6 +85,15 @@ AnimationClip: m_Extent: {x: 0, y: 0, z: 0} m_ClipBindingConstant: genericBindings: + - serializedVersion: 2 + path: 0 + attribute: 555744692 + script: {fileID: 0} + typeID: 212 + customType: 0 + isPPtrCurve: 0 + isIntCurve: 0 + isSerializeReferenceCurve: 0 - serializedVersion: 2 path: 0 attribute: 0 @@ -59,24 +105,23 @@ AnimationClip: isSerializeReferenceCurve: 0 pptrCurveMapping: - {fileID: 21300000, guid: eae7bedc4ba0bb44da9664f6f2ae65b0, type: 3} - - {fileID: 21300000, guid: a37285ebdc2fd7e419c0bfe4733bc263, type: 3} - {fileID: 21300000, guid: 6c5d88e222f01644c974b1fe56678bc4, type: 3} - - {fileID: 21300000, guid: d84da234fa9972e44a5a5af15235039d, type: 3} - - {fileID: 21300000, guid: 497fefedd06d8be4585f1a3cd1eeeb3f, type: 3} - {fileID: 21300000, guid: 61363c0901fc4ea469121a6c5e829f24, type: 3} - - {fileID: 21300000, guid: 587fa26a589bca040b756dae3592887a, type: 3} - {fileID: 21300000, guid: d011fbed2a802ed4c87033485707790d, type: 3} + - {fileID: 21300000, guid: 587fa26a589bca040b756dae3592887a, type: 3} + - {fileID: 21300000, guid: a37285ebdc2fd7e419c0bfe4733bc263, type: 3} + - {fileID: 21300000, guid: 497fefedd06d8be4585f1a3cd1eeeb3f, type: 3} m_AnimationClipSettings: serializedVersion: 2 m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 0.51666665 + m_StopTime: 1.0166667 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 0 + m_LoopTime: 1 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 @@ -86,7 +131,46 @@ AnimationClip: m_KeepOriginalPositionXZ: 0 m_HeightFromFeet: 0 m_Mirror: 0 - m_EditorCurves: [] + m_EditorCurves: + - serializedVersion: 2 + curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 0.5 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_FlipX + path: + classID: 212 + script: {fileID: 0} + flags: 0 m_EulerEditorCurves: [] m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 diff --git a/Assets/Resources/Player1.prefab b/Assets/Resources/Player1.prefab index 7b17070..cd83e5d 100644 --- a/Assets/Resources/Player1.prefab +++ b/Assets/Resources/Player1.prefab @@ -274,6 +274,8 @@ GameObject: - component: {fileID: 1749848915408613053} - component: {fileID: 1949941092232239315} - component: {fileID: 1449424410418603396} + - component: {fileID: 1160419468000791564} + - component: {fileID: 1691493459240420355} m_Layer: 7 m_Name: Player1 m_TagString: Player @@ -331,7 +333,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} m_Name: m_EditorClassIdentifier: + onlyCallZeroHealthOnce: 1 maxHealth: 100 + damageTickDelay: 0.25 OnHealthZero: m_PersistentCalls: m_Calls: [] @@ -395,6 +399,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9c2ddf673a65d3d49bc9470e1a4572e4, type: 3} m_Name: m_EditorClassIdentifier: + animator: {fileID: 0} --- !u!114 &1749848915408613053 MonoBehaviour: m_ObjectHideFlags: 0 @@ -407,6 +412,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b69b92d72c7244443854899c4b700d9c, type: 3} m_Name: m_EditorClassIdentifier: + animationHandler: {fileID: 3878447480781341932} playerInput: {fileID: 1949941092232239315} otherPlayerAttack: {fileID: 0} playerMovement: {fileID: 651446758998956252} @@ -441,6 +447,34 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b097a132c072b72fbc7808ebf263e52, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &1160419468000791564 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3} + m_Name: + m_EditorClassIdentifier: + flipTrans: {fileID: 320690117028550720} + body: {fileID: 1508323898269695585} +--- !u!114 &1691493459240420355 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d4d58ce9310f45c42af5d8003f1a832c, type: 3} + m_Name: + m_EditorClassIdentifier: + StepInterval: 0.8 + Volume: 0.25 --- !u!1001 &6225877037457186740 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Player2.prefab b/Assets/Resources/Player2.prefab index 889c005..d0c1873 100644 --- a/Assets/Resources/Player2.prefab +++ b/Assets/Resources/Player2.prefab @@ -190,6 +190,8 @@ GameObject: - component: {fileID: 7071433868121438663} - component: {fileID: 1949941092232239315} - component: {fileID: 7729933180365677331} + - component: {fileID: 8956099385762146752} + - component: {fileID: 5150961666696654592} m_Layer: 7 m_Name: Player2 m_TagString: Player @@ -247,7 +249,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} m_Name: m_EditorClassIdentifier: + onlyCallZeroHealthOnce: 1 maxHealth: 100 + damageTickDelay: 0.25 OnHealthZero: m_PersistentCalls: m_Calls: [] @@ -311,6 +315,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9c2ddf673a65d3d49bc9470e1a4572e4, type: 3} m_Name: m_EditorClassIdentifier: + animator: {fileID: 0} --- !u!114 &7071433868121438663 MonoBehaviour: m_ObjectHideFlags: 0 @@ -323,6 +328,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b69b92d72c7244443854899c4b700d9c, type: 3} m_Name: m_EditorClassIdentifier: + animationHandler: {fileID: 3878447480781341932} playerInput: {fileID: 1949941092232239315} otherPlayerAttack: {fileID: 0} playerMovement: {fileID: 651446758998956252} @@ -344,7 +350,7 @@ MonoBehaviour: movement: {x: 0, y: 0} look: {x: 0, y: 0} whipAttack: 0 - useArrowKeys: 0 + useArrowKeys: 1 --- !u!114 &7729933180365677331 MonoBehaviour: m_ObjectHideFlags: 0 @@ -357,6 +363,34 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b097a132c072b72fbc7808ebf263e52, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &8956099385762146752 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3} + m_Name: + m_EditorClassIdentifier: + flipTrans: {fileID: 320690117028550720} + body: {fileID: 1508323898269695585} +--- !u!114 &5150961666696654592 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d4d58ce9310f45c42af5d8003f1a832c, type: 3} + m_Name: + m_EditorClassIdentifier: + StepInterval: 0.8 + Volume: 0.25 --- !u!1 &7787472247078384126 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index e578c2e..9b8ceca 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -1461,13 +1461,7 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} - insertIndex: -1 - addedObject: {fileID: 1579580571} - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} - insertIndex: -1 - addedObject: {fileID: 1579580572} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} --- !u!114 &869964774 stripped MonoBehaviour: @@ -1634,13 +1628,7 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} - insertIndex: -1 - addedObject: {fileID: 1254139636} - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} - insertIndex: -1 - addedObject: {fileID: 1254139637} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} --- !u!114 &1232208433 stripped MonoBehaviour: @@ -1749,33 +1737,6 @@ GameObject: m_CorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} m_PrefabInstance: {fileID: 1232208432} m_PrefabAsset: {fileID: 0} ---- !u!114 &1254139636 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1254139629} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3} - m_Name: - m_EditorClassIdentifier: - invert: 0 ---- !u!114 &1254139637 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1254139629} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d4d58ce9310f45c42af5d8003f1a832c, type: 3} - m_Name: - m_EditorClassIdentifier: - StepInterval: 0.8 - Volume: 0.25 --- !u!1 &1377274208 GameObject: m_ObjectHideFlags: 0 @@ -3272,33 +3233,6 @@ GameObject: m_CorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} m_PrefabInstance: {fileID: 869964773} m_PrefabAsset: {fileID: 0} ---- !u!114 &1579580571 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1579580564} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3} - m_Name: - m_EditorClassIdentifier: - invert: 0 ---- !u!114 &1579580572 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1579580564} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d4d58ce9310f45c42af5d8003f1a832c, type: 3} - m_Name: - m_EditorClassIdentifier: - StepInterval: 0.8 - Volume: 0.25 --- !u!1 &1600052931 GameObject: m_ObjectHideFlags: 0 @@ -3755,6 +3689,10 @@ PrefabInstance: propertyPath: m_Targets.Array.data[1].target value: objectReference: {fileID: 1194834060} + - target: {fileID: 3603265075407754381, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3603265075407754381, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: players.Array.data[0] value: diff --git a/Assets/Scripts/Player/PlayerAnimationHandler.cs b/Assets/Scripts/Player/PlayerAnimationHandler.cs index 02cc3e5..bf62282 100644 --- a/Assets/Scripts/Player/PlayerAnimationHandler.cs +++ b/Assets/Scripts/Player/PlayerAnimationHandler.cs @@ -4,7 +4,7 @@ using UnityEngine; public class PlayerAnimationHandler : MonoBehaviour { - Animator animator; + public Animator animator; void Start() { @@ -19,9 +19,9 @@ public class PlayerAnimationHandler : MonoBehaviour { animator.SetBool("IsRunning", state); } - public void Swing() + public void Swing(bool state) { - animator.SetTrigger("Swing"); + animator.SetBool("IsSwinging", state); } public void Mop() { diff --git a/Assets/Scripts/Player/RopeWhipAttack.cs b/Assets/Scripts/Player/RopeWhipAttack.cs index a3e1ef1..b1cd6e1 100644 --- a/Assets/Scripts/Player/RopeWhipAttack.cs +++ b/Assets/Scripts/Player/RopeWhipAttack.cs @@ -3,9 +3,11 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using System.Linq; +using UnityUtils; public class RopeWhipAttack : MonoBehaviour { + [SerializeField] PlayerAnimationHandler animationHandler; [SerializeField] PlayerInput playerInput; public RopeWhipAttack otherPlayerAttack; @@ -28,13 +30,43 @@ public class RopeWhipAttack : MonoBehaviour if (playerInput.whipAttack) { + // reset local scale so rotations match up + transform.localScale = transform.localScale.With(x: 1f); + + animationHandler.Swing(true); + animationHandler.animator.speed = 0f; + float radianAngle = CalculateAngleBetwenRight(); + float sign = Mathf.Sign(radianAngle); + + //if (sign < 0) + // transform.localScale = transform.localScale.With(x: -1f); + //else + // transform.localScale = transform.localScale.With(x: 1f); + + float t = Mathf.Abs(radianAngle) / 360; + + if (sign > 0) + t -= (radianAngle - 180) / 180 * sign; + + //Debug.Log($"angle: {radianAngle}, t: {t}, sgn: {sign}"); + animationHandler.animator.Play("Swing", 0, t); joint.locked = true; otherPlayerAttack.joint.body.drag = 0f; } else { + animationHandler.Swing(false); + animationHandler.animator.speed = 1f; + animationHandler.animator.StopPlayback(); joint.locked = false; otherPlayerAttack.joint.body.drag = otherPlayerAttack.initialDrag; } } + + float CalculateAngleBetwenRight() + { + Vector2 ropeDir = (otherPlayerAttack.joint.anchor.position - joint.anchor.position).normalized; + float angle = Vector2.SignedAngle(Vector2.right, ropeDir); + return angle; + } } diff --git a/Assets/Scripts/Player/SpriteMovementFlipper.cs b/Assets/Scripts/Player/SpriteMovementFlipper.cs index 64b8105..c4e9b76 100644 --- a/Assets/Scripts/Player/SpriteMovementFlipper.cs +++ b/Assets/Scripts/Player/SpriteMovementFlipper.cs @@ -1,8 +1,10 @@ using UnityEngine; +using UnityUtils; public class SpriteMovementFlipper : MonoBehaviour { - [SerializeField] private bool invert = false; + [SerializeField] Transform flipTrans; + [SerializeField] Rigidbody2D body; SpriteRenderer sp; @@ -15,15 +17,13 @@ public class SpriteMovementFlipper : MonoBehaviour private void Update() { - if ((transform.position - prevPos).x > 0.05f) + if (body.velocity.x > 0.1f) { - sp.flipX = invert; + flipTrans.localScale = flipTrans.localScale.With(x: 1f); } - else if ((transform.position - prevPos).x < -0.05f) + else if (body.velocity.x < -0.1f) { - sp.flipX = !invert; + flipTrans.localScale = flipTrans.localScale.With(x: -1f); } - - prevPos = transform.position; } } \ No newline at end of file