From 549d4e590aff84ac15b46a1e7ac3ba6046332dd3 Mon Sep 17 00:00:00 2001 From: charnet3d Date: Sun, 28 Jan 2024 21:48:11 +0100 Subject: [PATCH] Punch Mechanic - Part 2 No punching while running Enemy can fight back Punch reaction animation --- Config/DefaultEngine.ini | 17 ++--- .../Meshes/SK_Mannequin_Skeleton.uasset | 4 +- .../Animations/Combat/PunchReaction1.uasset | 3 + .../Combat/PunchReaction_Montage.uasset | 3 + .../Animations/Combat/Punch_Montage.uasset | 4 +- .../Retargeted_UE4_Manny/ABP_SST.uasset | 4 +- .../Blueprints/BP_EnemyCharacter.uasset | 4 +- .../Blueprints/BP_FunnyPrinceCharacter.uasset | 4 +- .../Blueprints/BP_FunnyPrinceGameMode.uasset | 2 +- ...R_Mannequin_FootAdjustWithoutFullIK.uasset | 4 +- .../0/W3/BH9RA5CXGG4V6NBO45LIOY.uasset | 2 +- .../2/YS/0MUVLSZG6FOQLXF4C5BDRV.uasset | 3 + .../C/6K/SI4KJ8SJZN9L91M628EEFW.uasset | 3 - Source/FunnyPrince/EnemyCharacter.cpp | 10 +-- Source/FunnyPrince/EnemyCharacter.h | 1 - Source/FunnyPrince/FunnyPrinceCharacter.cpp | 67 ++++++++++++++----- Source/FunnyPrince/FunnyPrinceCharacter.h | 39 +++++++---- 17 files changed, 114 insertions(+), 60 deletions(-) create mode 100644 Content/SideScroller/Animations/Combat/PunchReaction1.uasset create mode 100644 Content/SideScroller/Animations/Combat/PunchReaction_Montage.uasset create mode 100644 Content/__ExternalActors__/SideScroller/Maps/ExampleMap/2/YS/0MUVLSZG6FOQLXF4C5BDRV.uasset delete mode 100644 Content/__ExternalActors__/SideScroller/Maps/ExampleMap/C/6K/SI4KJ8SJZN9L91M628EEFW.uasset diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 3c6be08..b6a8136 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -355,23 +355,23 @@ bEnableDomStorage=False -Profiles=(Name="UI",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Block),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ",bCanModify=False) +Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision") +Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=,HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ") -+Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") ++Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") +Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=,HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ") -+Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ") ++Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ") +Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that ignores Pawn and Vehicle. All other channels will be set to default.") -+Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ") ++Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ") +Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ") -+Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldStatic"),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.") -+Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.") ++Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.") ++Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.") +Profiles=(Name="PhysicsActor",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=,HelpMessage="Simulating actors") +Profiles=(Name="Destructible",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Destructible",CustomResponses=,HelpMessage="Destructible actors") +Profiles=(Name="InvisibleWall",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldStatic object that is invisible.") +Profiles=(Name="InvisibleWallDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that is invisible.") -+Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that is used for trigger. All other channels will be set to default.") ++Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that is used for trigger. All other channels will be set to default.") +Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.") +Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.") -+Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") -+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="Enemy") ++Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") ++DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Fighting") -ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall") -ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn") -ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic") @@ -390,4 +390,5 @@ bEnableDomStorage=False +CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic") +CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle") +CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn") ++CollisionChannelRedirects=(OldName="Enemy",NewName="Fighting") diff --git a/Content/Characters/Mannequin_UE4/Meshes/SK_Mannequin_Skeleton.uasset b/Content/Characters/Mannequin_UE4/Meshes/SK_Mannequin_Skeleton.uasset index d4b70e0..0a2af86 100644 --- a/Content/Characters/Mannequin_UE4/Meshes/SK_Mannequin_Skeleton.uasset +++ b/Content/Characters/Mannequin_UE4/Meshes/SK_Mannequin_Skeleton.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92d6c86a8587d89f3da1418d443ab0ff71dc215d2a6f42f6948a6f162e1ca09c -size 36690 +oid sha256:06ff7f1ee15c11e0a457936bb4dff950cf4de56b5cf229435293595909cb5bfc +size 36778 diff --git a/Content/SideScroller/Animations/Combat/PunchReaction1.uasset b/Content/SideScroller/Animations/Combat/PunchReaction1.uasset new file mode 100644 index 0000000..e2ebe32 --- /dev/null +++ b/Content/SideScroller/Animations/Combat/PunchReaction1.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea90f31b1cbe253a8601d40fd597697b8ec957737ae2d0cf5dc7fe48f2581edf +size 437525 diff --git a/Content/SideScroller/Animations/Combat/PunchReaction_Montage.uasset b/Content/SideScroller/Animations/Combat/PunchReaction_Montage.uasset new file mode 100644 index 0000000..596cb6d --- /dev/null +++ b/Content/SideScroller/Animations/Combat/PunchReaction_Montage.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e40eda421e4da30ee5fd90e659ed7979008d349d7f951a4891def6a865bddc25 +size 11131 diff --git a/Content/SideScroller/Animations/Combat/Punch_Montage.uasset b/Content/SideScroller/Animations/Combat/Punch_Montage.uasset index 414b703..6a230ea 100644 --- a/Content/SideScroller/Animations/Combat/Punch_Montage.uasset +++ b/Content/SideScroller/Animations/Combat/Punch_Montage.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fd567054e270d8bf89a442d8a3e0dcaec06b92fa01e5dd72c1b9eba5245c3226 -size 12280 +oid sha256:9e0e56f1304a740d777b1ec005f2ec7f95c28aadee8981d7b28b10a4a3443c45 +size 12271 diff --git a/Content/SideScroller/Animations/Retargeted_UE4_Manny/ABP_SST.uasset b/Content/SideScroller/Animations/Retargeted_UE4_Manny/ABP_SST.uasset index 513b08a..997b83d 100644 --- a/Content/SideScroller/Animations/Retargeted_UE4_Manny/ABP_SST.uasset +++ b/Content/SideScroller/Animations/Retargeted_UE4_Manny/ABP_SST.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0d3f5c5b9c3b279a24fbdca71e84c45f7b61f9b0f9d0de713e918a72b52c13ad -size 595395 +oid sha256:dda9afc0805e28f4b361e1686d02087e50b06150b639f2057bcbeb51387e8a5a +size 603544 diff --git a/Content/SideScroller/Blueprints/BP_EnemyCharacter.uasset b/Content/SideScroller/Blueprints/BP_EnemyCharacter.uasset index d527c88..a183522 100644 --- a/Content/SideScroller/Blueprints/BP_EnemyCharacter.uasset +++ b/Content/SideScroller/Blueprints/BP_EnemyCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b12b695a4b8c24b926b8e8f764378f1197190a736fa2b7b43cf4eaaf7cf5d3e -size 53813 +oid sha256:279d56ab5019fb9596acb16daed23a040acced1f8036d801a521a6cf5d3c0c70 +size 138475 diff --git a/Content/SideScroller/Blueprints/BP_FunnyPrinceCharacter.uasset b/Content/SideScroller/Blueprints/BP_FunnyPrinceCharacter.uasset index 460b6ce..d0a7d2b 100644 --- a/Content/SideScroller/Blueprints/BP_FunnyPrinceCharacter.uasset +++ b/Content/SideScroller/Blueprints/BP_FunnyPrinceCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:13b6e7f480b49bb42391aacec89db41c01ae3c6ad0a38f31d9591594b41b697d -size 167579 +oid sha256:3de60262b02fdaa54384f0774485876b853c13218481d299e7cf1cd14a1bf104 +size 169019 diff --git a/Content/SideScroller/Blueprints/BP_FunnyPrinceGameMode.uasset b/Content/SideScroller/Blueprints/BP_FunnyPrinceGameMode.uasset index 1a3ce83..ad87b0e 100644 --- a/Content/SideScroller/Blueprints/BP_FunnyPrinceGameMode.uasset +++ b/Content/SideScroller/Blueprints/BP_FunnyPrinceGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a9724698300c14ad099400bf814b1e77080d0666a63d1ddeba3e71437a85395 +oid sha256:c96831b3d8fc7accc0002786028f3f04c30349cc347500e1bc93080ba978dbf1 size 20537 diff --git a/Content/SideScroller/Rigs/CR_Mannequin_FootAdjustWithoutFullIK.uasset b/Content/SideScroller/Rigs/CR_Mannequin_FootAdjustWithoutFullIK.uasset index a859f7f..04d6815 100644 --- a/Content/SideScroller/Rigs/CR_Mannequin_FootAdjustWithoutFullIK.uasset +++ b/Content/SideScroller/Rigs/CR_Mannequin_FootAdjustWithoutFullIK.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cf249efd2264881a2364e49056d80c823453e76b2959feef413100a71f75d4d4 -size 497821 +oid sha256:1d15ecb486e62a8c25b29a5495904139f98c19f457f60c068dfd7fd41955dcce +size 495286 diff --git a/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/0/W3/BH9RA5CXGG4V6NBO45LIOY.uasset b/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/0/W3/BH9RA5CXGG4V6NBO45LIOY.uasset index dd6daa1..f31026e 100644 --- a/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/0/W3/BH9RA5CXGG4V6NBO45LIOY.uasset +++ b/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/0/W3/BH9RA5CXGG4V6NBO45LIOY.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3bad85f63ddd6bff05c28850fc6dd0fbdefe8c9eb700f3f761e184d6e9d4396e +oid sha256:8699b8e9f3b3df26e1d91a9d389beeff586a609b8b588520319dde7fe55012d8 size 4498 diff --git a/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/2/YS/0MUVLSZG6FOQLXF4C5BDRV.uasset b/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/2/YS/0MUVLSZG6FOQLXF4C5BDRV.uasset new file mode 100644 index 0000000..fd3ba2c --- /dev/null +++ b/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/2/YS/0MUVLSZG6FOQLXF4C5BDRV.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37752814a22df1e5d469618d6679444a4b0eee5f572113ba63fcbd4b4372c445 +size 7761 diff --git a/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/C/6K/SI4KJ8SJZN9L91M628EEFW.uasset b/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/C/6K/SI4KJ8SJZN9L91M628EEFW.uasset deleted file mode 100644 index f604609..0000000 --- a/Content/__ExternalActors__/SideScroller/Maps/ExampleMap/C/6K/SI4KJ8SJZN9L91M628EEFW.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0b4410871813490ed29d8121dc2d8efd85b11a345eea0ddc7d6d918c591240d7 -size 7169 diff --git a/Source/FunnyPrince/EnemyCharacter.cpp b/Source/FunnyPrince/EnemyCharacter.cpp index 94883e5..e782c83 100644 --- a/Source/FunnyPrince/EnemyCharacter.cpp +++ b/Source/FunnyPrince/EnemyCharacter.cpp @@ -2,6 +2,7 @@ #include "EnemyCharacter.h" +#include "EnhancedInputComponent.h" AEnemyCharacter::AEnemyCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -10,18 +11,19 @@ AEnemyCharacter::AEnemyCharacter(const FObjectInitializer& ObjectInitializer) void AEnemyCharacter::BeginPlay() { - /*GetWorldTimerManager().SetTimer(AutoPunch, this, &AEnemyCharacter::StartPunch, - 1.f);*/ + // Call the base class + Super::BeginPlay(); + GetWorldTimerManager().SetTimer(AutoPunch, this, &AEnemyCharacter::StartPunch, + 1.f); } void AEnemyCharacter::Tick(float DeltaTime) { + Super::Tick(DeltaTime); } void AEnemyCharacter::StartPunch() { - if (CanAttack) - UE_LOG(LogTemp, Warning, TEXT("Enemy StartPunch()")); Super::StartPunch(); GetWorldTimerManager().SetTimer(AutoPunch, this, &AEnemyCharacter::StartPunch, 1.f); diff --git a/Source/FunnyPrince/EnemyCharacter.h b/Source/FunnyPrince/EnemyCharacter.h index 835b2f3..fe64079 100644 --- a/Source/FunnyPrince/EnemyCharacter.h +++ b/Source/FunnyPrince/EnemyCharacter.h @@ -20,7 +20,6 @@ class FUNNYPRINCE_API AEnemyCharacter : public AFunnyPrinceCharacter public: AEnemyCharacter(const FObjectInitializer& ObjectInitializer); - protected: // To add mapping context virtual void BeginPlay() override; diff --git a/Source/FunnyPrince/FunnyPrinceCharacter.cpp b/Source/FunnyPrince/FunnyPrinceCharacter.cpp index 23a12ca..b06683c 100644 --- a/Source/FunnyPrince/FunnyPrinceCharacter.cpp +++ b/Source/FunnyPrince/FunnyPrinceCharacter.cpp @@ -3,10 +3,9 @@ #include "FunnyPrinceCharacter.h" #include "SSTCharacterMovementComponent.h" -#include "Components/InputComponent.h" +#include "EnhancedInputComponent.h" #include "Components/ArrowComponent.h" #include "EnhancedInputComponent.h" -#include "InputActionValue.h" #include "Engine/DamageEvents.h" #include "EnemyCharacter.h" @@ -17,14 +16,24 @@ DEFINE_LOG_CATEGORY(LogTemplateFunnyPrinceCharacter); // AFunnyPrinceCharacter AFunnyPrinceCharacter::AFunnyPrinceCharacter(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) + : Super(ObjectInitializer), + MoveAction2(nullptr), + PunchAction(nullptr), + PunchMontage(nullptr), + StartAttack(nullptr), + EndAttack(nullptr), + CanAttack(true), + MaxHealth(100), + Health(100), + PunchDamage(10), + CanMove(true) { StartAttack = CreateDefaultSubobject("StartAttack"); StartAttack->SetupAttachment(RootComponent); StartAttack->SetRelativeLocation(FVector(60.f, 0.f, 40.f)); StartAttack->SetArrowSize(0.5f); StartAttack->SetArrowLength(30.f); - + EndAttack = CreateDefaultSubobject("EndAttack"); EndAttack->SetupAttachment(RootComponent); @@ -50,6 +59,9 @@ void AFunnyPrinceCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInp // Set up action bindings if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked(PlayerInputComponent)) { + //Moving + EnhancedInputComponent->BindAction(MoveAction2, ETriggerEvent::Triggered, this, &AFunnyPrinceCharacter::Move); + // Punching EnhancedInputComponent->BindAction(PunchAction, ETriggerEvent::Started, this, &AFunnyPrinceCharacter::StartPunch); } @@ -117,11 +129,8 @@ void AFunnyPrinceCharacter::StartPunch() if (AnimInstance && PunchMontage) { UE_LOG(LogTemp, Warning, TEXT("StartPunch()")); - //CanAttack = false; - if (Enemy && Enemy->GetMesh()->GetAnimInstance()) - { - Enemy->GetMesh()->GetAnimInstance()->Montage_Play(Enemy->PunchMontage); - } + CanAttack = false; + CanMove = false; AnimInstance->Montage_Play(PunchMontage); //AnimInstance->Montage_JumpToSection(FName("StartFire")); } @@ -130,6 +139,7 @@ void AFunnyPrinceCharacter::StartPunch() void AFunnyPrinceCharacter::FinishPunching() { + CanMove = true; CanAttack = true; } @@ -142,16 +152,25 @@ void AFunnyPrinceCharacter::PunchHitTrace() FVector start = StartAttack->GetSocketLocation(FName()); FVector end = EndAttack->GetSocketLocation(FName()); - FCollisionQueryParams Params; - Params.AddIgnoredActor(this); - bool bSuccess = GetWorld()->LineTraceSingleByChannel(PunchTraceHit, start, end, ECollisionChannel::ECC_GameTraceChannel1, Params); + /*FCollisionQueryParams Params; + Params.AddIgnoredActor(this);*/ + bool bSuccess = GetWorld()->LineTraceSingleByChannel(PunchTraceHit, start, end, ECollisionChannel::ECC_GameTraceChannel1); if (bSuccess) { - AActor* HitActor = PunchTraceHit.GetActor(); - if (HitActor) + AFunnyPrinceCharacter* HitEnemy = Cast(PunchTraceHit.GetActor()); + if (HitEnemy) { FPointDamageEvent DamageEvent(PunchDamage, PunchTraceHit, end - start, nullptr); - HitActor->TakeDamage(PunchDamage, DamageEvent, GetController(), this); + HitEnemy->TakeDamage(PunchDamage, DamageEvent, GetController(), this); + + UAnimInstance* AnimInstance = HitEnemy->GetMesh()->GetAnimInstance(); + if (AnimInstance && PunchReactionMontage) + { + UE_LOG(LogTemp, Warning, TEXT("Punch Reaction")); + HitEnemy->CanAttack = false; + HitEnemy->CanMove = false; + AnimInstance->Montage_Play(PunchReactionMontage); + } } } /*UE_LOG(LogTemp, Warning, TEXT("TraceHit from %f %f %f to %f %f %f"), @@ -162,7 +181,21 @@ void AFunnyPrinceCharacter::PunchHitTrace() end.Y, end.Z);*/ - // (World, Start, End, Color, Persistent Lines, Life Time, Depth Priority, Thickness) - DrawDebugLine(GetWorld(), start, end, FColor(255, 0, 0), false, 1, 0, 5); + // (World, Start, End, Color, Persistent Lines, Life Time, Depth Priority, Thickness) + //DrawDebugLine(GetWorld(), start, end, FColor(255, 0, 0), false, 1, 0, 5); } } + +void AFunnyPrinceCharacter::FinishPunchReaction() +{ + CanMove = true; + CanAttack = true; +} + +void AFunnyPrinceCharacter::Move(const FInputActionValue& Value) +{ + if (CanMove) + { + Super::Move(Value); + } +} \ No newline at end of file diff --git a/Source/FunnyPrince/FunnyPrinceCharacter.h b/Source/FunnyPrince/FunnyPrinceCharacter.h index f5e77e6..aa26bec 100644 --- a/Source/FunnyPrince/FunnyPrinceCharacter.h +++ b/Source/FunnyPrince/FunnyPrinceCharacter.h @@ -44,6 +44,8 @@ protected: virtual bool CanJumpInternal_Implementation() const override; + void Move(const struct FInputActionValue& Value); + virtual void StartPunch(); UFUNCTION(BlueprintCallable) @@ -52,41 +54,52 @@ protected: UFUNCTION(BlueprintCallable) void PunchHitTrace(); + UFUNCTION(BlueprintCallable) + void FinishPunchReaction(); + + /** Move Input Action */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = true)) + TObjectPtr MoveAction2; + /** Punch Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = true)) - TObjectPtr PunchAction = nullptr; + TObjectPtr PunchAction; /** Punch Montage */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true)) - UAnimMontage* PunchMontage = nullptr; + UAnimMontage* PunchMontage; + + /** Punch Reaction Montage */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true)) + UAnimMontage* PunchReactionMontage; /** Punch Start Position */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true)) - UArrowComponent* StartAttack = nullptr; + UArrowComponent* StartAttack; /** Punch End Position */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true)) - UArrowComponent* EndAttack = nullptr; + UArrowComponent* EndAttack; /** Punch Input Action */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Combat, meta = (AllowPrivateAccess = true)) - bool CanAttack = true; + bool CanAttack; - UPROPERTY(EditDefaultsOnly) - float MaxHealth = 100; + UPROPERTY(EditAnywhere) + float MaxHealth; /** Current Health */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Combat, meta = (AllowPrivateAccess = true)) - float Health = 100; + float Health; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true)) - float PunchDamage = 10; - - /** Punch End Position */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true)) - TSoftObjectPtr Enemy = nullptr; + float PunchDamage; + /** Whether the player can move */ + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Combat, meta = (AllowPrivateAccess = true)) + bool CanMove; private: + public: };