Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 72e9caf2c1 | |||
| 0da3851dde | |||
|
|
469451e491 | ||
| 064d4cd576 | |||
|
|
c8f3f53a8f | ||
|
|
6305198eda | ||
|
|
9ddc2fdbed | ||
|
|
7a9a6d257a | ||
|
|
49685ed167 | ||
|
|
ed5475299e | ||
|
|
406bafff0a | ||
|
|
d2968f0d36 | ||
|
|
365727aa4c | ||
|
|
c7702b9f64 | ||
|
|
5624625eda | ||
|
|
17c6475397 | ||
|
|
f57f6b8832 | ||
|
|
8733dfd87f |
@@ -103,4 +103,62 @@ ManualIPAddress=
|
|||||||
|
|
||||||
[CoreRedirects]
|
[CoreRedirects]
|
||||||
+ClassRedirects=(OldName="/Script/M4_CPP.M4_CentipedeController",NewName="/Script/M4_CPP.M4_CentipedeController")
|
+ClassRedirects=(OldName="/Script/M4_CPP.M4_CentipedeController",NewName="/Script/M4_CPP.M4_CentipedeController")
|
||||||
|
+FunctionRedirects=(OldName="/Script/M4_CPP.M4_CentipedeController.OnSegmentDestroyed",NewName="/Script/M4_CPP.M4_CentipedeController.OnSegmentHit")
|
||||||
|
|
||||||
|
[/Script/Engine.CollisionProfile]
|
||||||
|
-Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision",bCanModify=False)
|
||||||
|
-Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldStatic",CustomResponses=,HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
|
||||||
|
-Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,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. ",bCanModify=False)
|
||||||
|
-Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldDynamic",CustomResponses=,HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
|
||||||
|
-Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,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. ",bCanModify=False)
|
||||||
|
-Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,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.",bCanModify=False)
|
||||||
|
-Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,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. ",bCanModify=False)
|
||||||
|
-Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ",bCanModify=False)
|
||||||
|
-Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldStatic",Response=ECR_Block),(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.",bCanModify=False)
|
||||||
|
-Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,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.",bCanModify=False)
|
||||||
|
-Profiles=(Name="PhysicsActor",CollisionEnabled=QueryAndPhysics,ObjectTypeName="PhysicsBody",CustomResponses=,HelpMessage="Simulating actors",bCanModify=False)
|
||||||
|
-Profiles=(Name="Destructible",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Destructible",CustomResponses=,HelpMessage="Destructible actors",bCanModify=False)
|
||||||
|
-Profiles=(Name="InvisibleWall",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldStatic object that is invisible.",bCanModify=False)
|
||||||
|
-Profiles=(Name="InvisibleWallDynamic",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that is invisible.",bCanModify=False)
|
||||||
|
-Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,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.",bCanModify=False)
|
||||||
|
-Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,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.",bCanModify=False)
|
||||||
|
-Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.",bCanModify=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="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="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="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="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="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_Block,bTraceType=False,bStaticObject=False,Name="Projectile")
|
||||||
|
-ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
|
||||||
|
-ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
|
||||||
|
-ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic")
|
||||||
|
-ProfileRedirects=(OldName="SkeletalMeshActor",NewName="PhysicsActor")
|
||||||
|
-ProfileRedirects=(OldName="InvisibleActor",NewName="InvisibleWallDynamic")
|
||||||
|
+ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
|
||||||
|
+ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
|
||||||
|
+ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic")
|
||||||
|
+ProfileRedirects=(OldName="SkeletalMeshActor",NewName="PhysicsActor")
|
||||||
|
+ProfileRedirects=(OldName="InvisibleActor",NewName="InvisibleWallDynamic")
|
||||||
|
-CollisionChannelRedirects=(OldName="Static",NewName="WorldStatic")
|
||||||
|
-CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic")
|
||||||
|
-CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
|
||||||
|
-CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
|
||||||
|
+CollisionChannelRedirects=(OldName="Static",NewName="WorldStatic")
|
||||||
|
+CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic")
|
||||||
|
+CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
|
||||||
|
+CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
|
||||||
|
|
||||||
|
|||||||
BIN
Content/CTP/03_Input/IA_Shoot.uasset
Normal file
BIN
Content/CTP/03_Input/IA_Shoot.uasset
Normal file
Binary file not shown.
Binary file not shown.
BIN
Content/CTP/04_Mesh/SM_Projectile.uasset
Normal file
BIN
Content/CTP/04_Mesh/SM_Projectile.uasset
Normal file
Binary file not shown.
Binary file not shown.
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
UM4_CentipedeController::UM4_CentipedeController()
|
UM4_CentipedeController::UM4_CentipedeController()
|
||||||
{
|
{
|
||||||
|
SegmentRemainingCount = BodyCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UM4_CentipedeController::Initialize(FSubsystemCollectionBase& Collection)
|
void UM4_CentipedeController::Initialize(FSubsystemCollectionBase& Collection)
|
||||||
@@ -90,11 +90,11 @@ TStatId UM4_CentipedeController::GetStatId() const
|
|||||||
|
|
||||||
void UM4_CentipedeController::SpawnCentipede()
|
void UM4_CentipedeController::SpawnCentipede()
|
||||||
{
|
{
|
||||||
AM4_Gamemode* GM = Cast<AM4_Gamemode>(GetWorld()->GetAuthGameMode());
|
GM_REF_PTR = Cast<AM4_Gamemode>(GetWorld()->GetAuthGameMode());
|
||||||
if (!GM) return;
|
if (!GM_REF_PTR) return;
|
||||||
|
|
||||||
FVector SpawnLocation = FVector(
|
FVector SpawnLocation = FVector(
|
||||||
GM->MushroomSpawnBounds.Max.X,
|
GM_REF_PTR->MushroomSpawnBounds.Max.X,
|
||||||
0.f,
|
0.f,
|
||||||
0.f
|
0.f
|
||||||
);
|
);
|
||||||
@@ -201,13 +201,16 @@ bool UM4_CentipedeController::CheckCollision(AM4_CentipedeBody* Segment, FVector
|
|||||||
FVector CurrentPos = Segment->GetActorLocation();
|
FVector CurrentPos = Segment->GetActorLocation();
|
||||||
FVector NextPos = CurrentPos + FVector(0.f, Direction.Y * CellSize, 0.f);
|
FVector NextPos = CurrentPos + FVector(0.f, Direction.Y * CellSize, 0.f);
|
||||||
|
|
||||||
AM4_Gamemode* GM = Cast<AM4_Gamemode>(GetWorld()->GetAuthGameMode());
|
if (!GM_REF_PTR)
|
||||||
if (!GM) return false;
|
{
|
||||||
|
GM_REF_PTR = Cast<AM4_Gamemode>(GetWorld()->GetAuthGameMode());
|
||||||
|
if (!GM_REF_PTR) return false;
|
||||||
|
}
|
||||||
|
|
||||||
const float LeftBound = GM->MushroomSpawnBounds.Min.Y;
|
const float LeftBound = GM_REF_PTR->MushroomSpawnBounds.Min.Y;
|
||||||
const float RightBound = GM->MushroomSpawnBounds.Max.Y;
|
const float RightBound = GM_REF_PTR->MushroomSpawnBounds.Max.Y;
|
||||||
const float MinRows = GM->MushroomSpawnBounds.Min.X;
|
const float MinRows = GM_REF_PTR->MushroomSpawnBounds.Min.X;
|
||||||
const float MaxRows = GM->MushroomSpawnBounds.Max.X;
|
const float MaxRows = GM_REF_PTR->MushroomSpawnBounds.Max.X;
|
||||||
|
|
||||||
if (NextPos.Y <= LeftBound || NextPos.Y >= RightBound)
|
if (NextPos.Y <= LeftBound || NextPos.Y >= RightBound)
|
||||||
{
|
{
|
||||||
@@ -290,7 +293,7 @@ void UM4_CentipedeController::UpdateHeadStatus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UM4_CentipedeController::OnSegmentDestroyed(AM4_CentipedeBody* DestroyedSegment)
|
void UM4_CentipedeController::OnSegmentHit(AM4_CentipedeBody* DestroyedSegment)
|
||||||
{
|
{
|
||||||
if (!DestroyedSegment) return;
|
if (!DestroyedSegment) return;
|
||||||
|
|
||||||
@@ -312,7 +315,33 @@ void UM4_CentipedeController::OnSegmentDestroyed(AM4_CentipedeBody* DestroyedSeg
|
|||||||
BodySegments[SegmentIndex - 1]->NextBody = nullptr;
|
BodySegments[SegmentIndex - 1]->NextBody = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
BodySegments.RemoveAt(SegmentIndex);
|
// disable collision and hide the destroyed segment
|
||||||
SegmentHistory.RemoveAt(SegmentIndex);
|
DestroyedSegment->GetStaticMeshComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
SegmentDirections.Remove(DestroyedSegment);
|
DestroyedSegment->SetActorHiddenInGame(true);
|
||||||
|
// Increase player score
|
||||||
|
if (!GM_REF_PTR)
|
||||||
|
{
|
||||||
|
GM_REF_PTR = Cast<AM4_Gamemode>(GetWorld()->GetAuthGameMode());
|
||||||
|
if (!GM_REF_PTR) return;
|
||||||
|
}
|
||||||
|
GM_REF_PTR->AddScore(100);
|
||||||
|
SpawnMushroomsAtSegmentDeathPos(DestroyedSegment->GetActorLocation());
|
||||||
|
// Decresase the remaining segment count and check if all segments are destroyed
|
||||||
|
SegmentRemainingCount--;
|
||||||
|
if (SegmentRemainingCount <= 0)
|
||||||
|
{
|
||||||
|
// TODO: Trigger level complete or respawn centipede
|
||||||
|
UE_LOG(M4_CPP, Warning, TEXT("All centipede segments destroyed!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UM4_CentipedeController::SpawnMushroomsAtSegmentDeathPos(FVector Location)
|
||||||
|
{
|
||||||
|
FVector Offset = FVector(0.f, FMath::RandRange(-CellSize, CellSize), 0.f);
|
||||||
|
FVector SpawnLocation = Location + Offset;
|
||||||
|
GetWorld()->SpawnActor<AM4_Mushroom>(
|
||||||
|
AM4_Mushroom::StaticClass(),
|
||||||
|
SpawnLocation,
|
||||||
|
FRotator::ZeroRotator
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "M4_CTP_Macros.h"
|
#include "M4_CTP_Macros.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "M4_Gamemode.h"
|
#include "M4_Gamemode.h"
|
||||||
|
#include "M4_Projectile.h"
|
||||||
|
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
@@ -31,12 +32,29 @@ AM4_Mushroom::AM4_Mushroom()
|
|||||||
const FVector2D MushroomScale = FVector2D(0.3f, 0.25f);
|
const FVector2D MushroomScale = FVector2D(0.3f, 0.25f);
|
||||||
GetStaticMeshComponent()->SetRelativeScale3D(FVector(1.f, 0.45f, 0.20f));
|
GetStaticMeshComponent()->SetRelativeScale3D(FVector(1.f, 0.45f, 0.20f));
|
||||||
|
|
||||||
// Set collision profile to overlap all
|
// Set collision profile to block all
|
||||||
GetStaticMeshComponent()->SetCollisionProfileName(TEXT("OverlapAll"));
|
GetStaticMeshComponent()->SetCollisionProfileName(TEXT("OverlapAll"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AM4_Mushroom::BeginPlay()
|
void AM4_Mushroom::BeginPlay()
|
||||||
{
|
{
|
||||||
|
MushLife = 2;
|
||||||
|
DestructionHit = 0;
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AM4_Mushroom::OnHit(UPrimitiveComponent* HitComp,AActor* OtherActor,UPrimitiveComponent* OtherComp,FVector NormalImpulse,const FHitResult& Hit)
|
||||||
|
{
|
||||||
|
|
||||||
|
AM4_Projectile* Projectile = Cast<AM4_Projectile>(OtherActor);
|
||||||
|
if (!Projectile)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DestructionHit++ == MushLife)
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
#include "M4_PlayerPawn.h"
|
#include "M4_PlayerPawn.h"
|
||||||
#include "EnhancedInputComponent.h"
|
#include "EnhancedInputComponent.h"
|
||||||
#include "M4_Gamemode.h"
|
#include "M4_Gamemode.h"
|
||||||
|
#include "M4_LOG.h"
|
||||||
|
#include "M4_Projectile.h"
|
||||||
#include "GameFramework/PlayerController.h"
|
#include "GameFramework/PlayerController.h"
|
||||||
#include "Camera/CameraComponent.h"
|
|
||||||
|
|
||||||
AM4_PlayerPawn::AM4_PlayerPawn()
|
AM4_PlayerPawn::AM4_PlayerPawn()
|
||||||
{
|
{
|
||||||
@@ -16,10 +17,16 @@ AM4_PlayerPawn::AM4_PlayerPawn()
|
|||||||
MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));
|
MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));
|
||||||
MeshComponent->SetupAttachment(RootComponent);
|
MeshComponent->SetupAttachment(RootComponent);
|
||||||
MeshComponent->SetMobility(EComponentMobility::Movable);
|
MeshComponent->SetMobility(EComponentMobility::Movable);
|
||||||
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
|
||||||
MeshComponent->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);
|
|
||||||
MeshComponent->SetRelativeScale3D(FVector(1.0f, MeshScale.Y, MeshScale.X));
|
|
||||||
|
|
||||||
|
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
||||||
|
MeshComponent->SetCollisionObjectType(ECC_Pawn);
|
||||||
|
MeshComponent->SetCollisionResponseToAllChannels(ECR_Block);
|
||||||
|
|
||||||
|
MeshComponent->SetGenerateOverlapEvents(true);
|
||||||
|
|
||||||
|
MeshComponent->OnComponentBeginOverlap.AddDynamic(this,&AM4_PlayerPawn::OnPlayerOverlap);
|
||||||
|
|
||||||
|
MeshComponent->SetRelativeScale3D(FVector(1.0f, MeshScale.Y, MeshScale.X));
|
||||||
|
|
||||||
static ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultMeshRef(TEXT("/Game/CTP/04_Mesh/SM_Cube.SM_Cube"));
|
static ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultMeshRef(TEXT("/Game/CTP/04_Mesh/SM_Cube.SM_Cube"));
|
||||||
if (DefaultMeshRef.Succeeded())
|
if (DefaultMeshRef.Succeeded())
|
||||||
@@ -32,12 +39,18 @@ AM4_PlayerPawn::AM4_PlayerPawn()
|
|||||||
{
|
{
|
||||||
MoveAction = MoveActionRef.Object;
|
MoveAction = MoveActionRef.Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ConstructorHelpers::FObjectFinder<UInputAction> ShootActionRef(TEXT("/Game/CTP/03_Input/IA_Shoot.IA_Shoot"));
|
||||||
|
if (ShootActionRef.Succeeded())
|
||||||
|
{
|
||||||
|
ShootAction = ShootActionRef.Object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AM4_PlayerPawn::BeginPlay()
|
void AM4_PlayerPawn::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
SetActorLocation(FVector(0.0f, 0.0f, -400.0f));
|
SetActorLocation(FVector(-400.0f, 0.0f, -400.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AM4_PlayerPawn::Tick(float DeltaTime)
|
void AM4_PlayerPawn::Tick(float DeltaTime)
|
||||||
@@ -51,8 +64,6 @@ void AM4_PlayerPawn::Tick(float DeltaTime)
|
|||||||
NewLocation.Y = FMath::Clamp(NewLocation.Y, GM->Bounds.Min.Y, GM->Bounds.Max.Y);
|
NewLocation.Y = FMath::Clamp(NewLocation.Y, GM->Bounds.Min.Y, GM->Bounds.Max.Y);
|
||||||
SetActorLocation(NewLocation);
|
SetActorLocation(NewLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AM4_PlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
void AM4_PlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||||
@@ -64,10 +75,71 @@ void AM4_PlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
|
|||||||
{
|
{
|
||||||
Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AM4_PlayerPawn::Move);
|
Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AM4_PlayerPawn::Move);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ShootAction)
|
||||||
|
{
|
||||||
|
Input->BindAction(ShootAction, ETriggerEvent::Triggered, this, &AM4_PlayerPawn::Shoot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AM4_PlayerPawn::Move(const FInputActionInstance& Instance)
|
void AM4_PlayerPawn::Move(const FInputActionInstance& Instance)
|
||||||
{
|
{
|
||||||
LastMoveValue = Instance.GetValue().Get<FVector2D>().GetSafeNormal();
|
LastMoveValue = Instance.GetValue().Get<FVector2D>().GetSafeNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst)
|
||||||
|
{
|
||||||
|
if (Proj)
|
||||||
|
{
|
||||||
|
UWorld* World = GetWorld();
|
||||||
|
|
||||||
|
if (World)
|
||||||
|
{
|
||||||
|
FActorSpawnParameters SpawnParams;
|
||||||
|
SpawnParams.Owner = this;
|
||||||
|
const FVector InitialLocation = FVector(-400.f, GetActorLocation().Y, GetActorLocation().Z);
|
||||||
|
const FRotator InitialRotation = FRotator(0.f);
|
||||||
|
AM4_Projectile* Projectile = World->SpawnActor<AM4_Projectile>(Proj, InitialLocation, InitialRotation, SpawnParams);
|
||||||
|
if (Projectile)
|
||||||
|
{
|
||||||
|
Projectile->FireInDir(InitialLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void AM4_PlayerPawn::OnPlayerOverlap(
|
||||||
|
UPrimitiveComponent* OverlappedComponent,
|
||||||
|
AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp,
|
||||||
|
int32 OtherBodyIndex,
|
||||||
|
bool bFromSweep,
|
||||||
|
const FHitResult& SweepResult)
|
||||||
|
{
|
||||||
|
if (!OtherActor || OtherActor == this || bIsInvincible)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AM4_CentipedeBody* CentipedeSegment = Cast<AM4_CentipedeBody>(OtherActor);
|
||||||
|
if (CentipedeSegment)
|
||||||
|
{
|
||||||
|
UE_LOG(M4_CPP, Warning, TEXT("Player collided with Centipede Segment!"));
|
||||||
|
|
||||||
|
if (AM4_Gamemode* GM = Cast<AM4_Gamemode>(GetWorld()->GetAuthGameMode()))
|
||||||
|
{
|
||||||
|
GM->LoseLife();
|
||||||
|
UE_LOG(M4_CPP, Warning, TEXT("Player Lives Remaining: %d"), GM->GetLives());
|
||||||
|
|
||||||
|
bIsInvincible = true;
|
||||||
|
GetWorldTimerManager().SetTimer(InvincibleTimerHandle,this, &AM4_PlayerPawn::EndInvincibility, InvinciblityDuration, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AM4_PlayerPawn::EndInvincibility()
|
||||||
|
{
|
||||||
|
bIsInvincible = false;
|
||||||
|
UE_LOG(M4_CPP, Warning, TEXT("Player invincibility ended."));
|
||||||
}
|
}
|
||||||
@@ -1,35 +1,108 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
#include "M4_Projectile.h"
|
||||||
|
|
||||||
|
|
||||||
#include "M4_Projectile.h"
|
|
||||||
#include "GameFramework/ProjectileMovementComponent.h"
|
|
||||||
#include "Components/MeshComponent.h"
|
#include "Components/MeshComponent.h"
|
||||||
|
#include "M4_Gamemode.h"
|
||||||
|
#include "M4_Mushroom.h"
|
||||||
|
#include "Components/SphereComponent.h"
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
AM4_Projectile::AM4_Projectile()
|
AM4_Projectile::AM4_Projectile()
|
||||||
{
|
{
|
||||||
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
MeshComp-> SetRelativeScale3D(FVector(1.f, .1f,.1f));
|
|
||||||
MeshComp->BodyInstance.SetCollisionProfileName(TEXT("Projectile"));
|
// Crée d'abord le composant de collision comme root
|
||||||
MeshComp->OnComponentHit.AddDynamic(this, &AM4_Projectile::OnHit);
|
CollisionComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComponent"));
|
||||||
|
CollisionComp->InitSphereRadius(15.0f);
|
||||||
|
CollisionComp->SetCollisionProfileName(TEXT("Projectile"));
|
||||||
|
CollisionComp->OnComponentBeginOverlap.AddDynamic(this, &AM4_Projectile::OnOverlap);
|
||||||
|
CollisionComp->SetGenerateOverlapEvents(true);
|
||||||
|
RootComponent = CollisionComp;
|
||||||
|
|
||||||
|
// Ensuite attache le mesh au composant de collision
|
||||||
|
ProjectileMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMeshComponent"));
|
||||||
|
ProjectileMeshComponent->SetupAttachment(RootComponent);
|
||||||
|
ProjectileMeshComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision); // Le mesh ne gère pas la collision
|
||||||
|
|
||||||
|
static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("/Game/CTP/04_Mesh/SM_Projectile.SM_Projectile"));
|
||||||
|
if(Mesh.Succeeded())
|
||||||
|
{
|
||||||
|
ProjectileMeshComponent->SetStaticMesh(Mesh.Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ConstructorHelpers::FObjectFinder<UMaterial> Material(TEXT("/Game/CTP/05_Material/M_Player.M_Player"));
|
||||||
|
if (Material.Succeeded())
|
||||||
|
{
|
||||||
|
ProjectileMat = UMaterialInstanceDynamic::Create(Material.Object, ProjectileMeshComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectileMeshComponent->SetMaterial(0, ProjectileMat);
|
||||||
|
ProjectileMeshComponent->SetRelativeScale3D(FVector(.3f, .3f, .35f));
|
||||||
|
ProjectileMeshComponent->SetMobility(EComponentMobility::Movable);
|
||||||
|
ProjectileMeshComponent->SetRelativeLocation(FVector::ZeroVector);
|
||||||
|
|
||||||
|
// Configure le ProjectileMovementComponent
|
||||||
|
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComponent"));
|
||||||
|
ProjectileMovementComponent->SetUpdatedComponent(CollisionComp); // Maintenant CollisionComp existe
|
||||||
|
ProjectileMovementComponent->InitialSpeed = 380.f;
|
||||||
|
ProjectileMovementComponent->MaxSpeed = 380.f;
|
||||||
|
ProjectileMovementComponent->bRotationFollowsVelocity = false;
|
||||||
|
ProjectileMovementComponent->bShouldBounce = false;
|
||||||
|
ProjectileMovementComponent->ProjectileGravityScale = 0.0f;
|
||||||
|
|
||||||
|
InitialLifeSpan = 10.f;
|
||||||
}
|
}
|
||||||
|
///FAIRE SUPER GAFFE AUX INDENTATIONS ET LES FOR LOOPS sont à bien faire.
|
||||||
|
///Ce qui est critique dans notre code doit être vraiment bien mis en évidence sans être obscurci par la boucle.
|
||||||
|
///Gestion des pointeurs à revoir, lisibilité des fonctions critiques
|
||||||
|
|
||||||
void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector Impulse, const FHitResult& Hit)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Called when the game starts or when spawned
|
|
||||||
void AM4_Projectile::BeginPlay()
|
void AM4_Projectile::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
InitialLoc = GetActorLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
Called every frame
|
void AM4_Projectile::OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("Projectile OVERLAP: %s"), *OtherActor->GetName());
|
||||||
|
|
||||||
|
if (!OtherActor || OtherActor == this || !OtherComp)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AM4_Mushroom* Mushroom = Cast<AM4_Mushroom>(OtherActor);
|
||||||
|
if (Mushroom)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("OVERLAP MUSHROOM!"));
|
||||||
|
|
||||||
|
FVector NormalImpulse = FVector::ZeroVector;
|
||||||
|
Mushroom->OnHit(OverlappedComponent, this, OtherComp, NormalImpulse, SweepResult);
|
||||||
|
Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AM4_CentipedeBody* CentipedeBody = Cast<AM4_CentipedeBody>(OtherActor);
|
||||||
|
if (CentipedeBody)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("OVERLAP CENTIPEDE BODY!"));
|
||||||
|
UM4_CentipedeController* CentipedeController = GetWorld()->GetSubsystem<UM4_CentipedeController>();
|
||||||
|
if (CentipedeController)
|
||||||
|
{
|
||||||
|
CentipedeController->OnSegmentHit(CentipedeBody);
|
||||||
|
}
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AM4_Projectile::FireInDir(const FVector& ShootDir)
|
||||||
|
{
|
||||||
|
SetActorLocation(InitialLoc);
|
||||||
|
ProjectileMovementComponent->Velocity.Z = -1 * ((ShootDir.Z + 380.f) * ProjectileMovementComponent->InitialSpeed);
|
||||||
|
ProjectileMovementComponent->Velocity.X = 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame
|
||||||
void AM4_Projectile::Tick(float DeltaTime)
|
void AM4_Projectile::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick( DeltaTime);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
@@ -31,13 +31,14 @@ public:
|
|||||||
float MoveInterval = 0.1f;
|
float MoveInterval = 0.1f;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Centipede")
|
UFUNCTION(BlueprintCallable, Category = "Centipede")
|
||||||
void OnSegmentDestroyed(AM4_CentipedeBody* DestroyedSegment);
|
void OnSegmentHit(AM4_CentipedeBody* DestroyedSegment);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TArray<AM4_CentipedeBody*> BodySegments;
|
TArray<AM4_CentipedeBody*> BodySegments;
|
||||||
TArray<TArray<FVector>> SegmentHistory; // Historique pour chaque segment
|
TArray<TArray<FVector>> SegmentHistory; // Historique pour chaque segment
|
||||||
int32 MaxHistorySize = 200;
|
int32 MaxHistorySize = 200;
|
||||||
|
int8 SegmentRemainingCount = 0;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Centipede")
|
UPROPERTY(EditAnywhere, Category = "Centipede")
|
||||||
int32 SegmentSpacing = 15; // Distance en nombre de frames entre segments
|
int32 SegmentSpacing = 15; // Distance en nombre de frames entre segments
|
||||||
@@ -52,9 +53,13 @@ private:
|
|||||||
|
|
||||||
void SpawnCentipede();
|
void SpawnCentipede();
|
||||||
void UpdateHeadStatus();
|
void UpdateHeadStatus();
|
||||||
|
void SpawnMushroomsAtSegmentDeathPos(FVector Location);
|
||||||
|
|
||||||
bool CheckCollision(AM4_CentipedeBody* Segment, FVector2D Direction);
|
bool CheckCollision(AM4_CentipedeBody* Segment, FVector2D Direction);
|
||||||
|
|
||||||
FVector2D GetSegmentDirection(AM4_CentipedeBody* Segment);
|
FVector2D GetSegmentDirection(AM4_CentipedeBody* Segment);
|
||||||
void SetSegmentDirection(AM4_CentipedeBody* Segment, FVector2D Direction);
|
void SetSegmentDirection(AM4_CentipedeBody* Segment, FVector2D Direction);
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
class AM4_Gamemode* GM_REF_PTR;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,9 +13,14 @@ class M4_CPP_API AM4_Mushroom : public AStaticMeshActor
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Sets default values for this pawn's properties
|
|
||||||
AM4_Mushroom();
|
AM4_Mushroom();
|
||||||
|
|
||||||
|
int MushLife;
|
||||||
|
int DestructionHit = 0;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnHit(UPrimitiveComponent* HitComp,AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse,const FHitResult& Hit);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "M4_Projectile.h"
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "GameFramework/Pawn.h"
|
#include "GameFramework/Pawn.h"
|
||||||
#include "InputAction.h"
|
#include "InputAction.h"
|
||||||
@@ -11,6 +12,7 @@ UCLASS()
|
|||||||
class AM4_PlayerPawn : public APawn
|
class AM4_PlayerPawn : public APawn
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AM4_PlayerPawn();
|
AM4_PlayerPawn();
|
||||||
|
|
||||||
@@ -18,6 +20,19 @@ public:
|
|||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
|
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
|
||||||
void Move(const FInputActionInstance& Instance);
|
void Move(const FInputActionInstance& Instance);
|
||||||
|
void Shoot(const FInputActionInstance& Inst);
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere)
|
||||||
|
TSubclassOf<AM4_Projectile> Proj = AM4_Projectile::StaticClass();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnPlayerOverlap(
|
||||||
|
UPrimitiveComponent* OverlappedComponent,
|
||||||
|
AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp,
|
||||||
|
int32 OtherBodyIndex,
|
||||||
|
bool bFromSweep,
|
||||||
|
const FHitResult& SweepResult);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -27,7 +42,19 @@ protected:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
UInputAction* MoveAction;
|
UInputAction* MoveAction;
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
UInputAction* ShootAction;
|
||||||
|
|
||||||
float MoveSpeed = 500.f;
|
float MoveSpeed = 500.f;
|
||||||
FVector2D MeshScale = FVector2D(0.6f, 0.5f);
|
FVector2D MeshScale = FVector2D(0.6f, 0.5f);
|
||||||
FVector2D LastMoveValue = FVector2D::ZeroVector;
|
FVector2D LastMoveValue = FVector2D::ZeroVector;
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
bool bIsInvincible = false;
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
float InvinciblityDuration = 2.0f;
|
||||||
|
|
||||||
|
FTimerHandle InvincibleTimerHandle;
|
||||||
|
void EndInvincibility();
|
||||||
};
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
#include "GameFramework/ProjectileMovementComponent.h"
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -6,31 +6,39 @@
|
|||||||
#include "GameFramework/Actor.h"
|
#include "GameFramework/Actor.h"
|
||||||
#include "M4_Projectile.generated.h"
|
#include "M4_Projectile.generated.h"
|
||||||
|
|
||||||
class UProjectileMovementComponent;
|
class USphereComponent;
|
||||||
class UMeshComponent;
|
class UMeshComponent;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class M4_CPP_API AM4_Projectile : public AActor
|
class M4_CPP_API AM4_Projectile : public AActor
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
|
||||||
UMeshComponent* MeshComp;
|
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere,BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = "true"))
|
|
||||||
UProjectileMovementComponent* ProjectileMovem;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AM4_Projectile();
|
AM4_Projectile();
|
||||||
|
|
||||||
protected:
|
virtual void Tick( float DeltaTime ) override;
|
||||||
float bullSpeed = 50.f;
|
virtual void BeginPlay() override;
|
||||||
float lifeTime = 3.f;
|
|
||||||
|
bool CollisionCheck = false;
|
||||||
|
FVector InitialLoc;
|
||||||
|
FVector NewLoc;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||||
|
USphereComponent* CollisionComp;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, Category = Movement)
|
||||||
|
UProjectileMovementComponent* ProjectileMovementComponent;
|
||||||
|
|
||||||
public:
|
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||||
|
UStaticMeshComponent* ProjectileMeshComponent;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||||
|
UMaterialInstanceDynamic* ProjectileMat;
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit);
|
void OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||||
UMeshComponent* GetCollisionComp() const { return MeshComp; }
|
void FireInDir(const FVector& ShootDir);
|
||||||
UProjectileMovementComponent* GetMovementComp() const { return ProjectileMovem; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user