From c8f3f53a8fb308746f387ff0a61162b015c5da6f Mon Sep 17 00:00:00 2001 From: NisemonoQ Date: Tue, 4 Nov 2025 17:02:24 +0100 Subject: [PATCH] Minor - Mushroom function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit J'ai ajouté une fonction au Mushroom pour enregistrer le hit de la balle lorsqu'il la touche, mais on dirait que ça ne veut pas marcher. --- Config/DefaultEngine.ini | 57 +++++++++++++++++++++++++ Source/M4_CPP/private/M4_Mushroom.cpp | 18 +++++++- Source/M4_CPP/private/M4_PlayerPawn.cpp | 4 +- Source/M4_CPP/private/M4_Projectile.cpp | 23 +++++++--- Source/M4_CPP/public/M4_Mushroom.h | 9 +++- Source/M4_CPP/public/M4_Projectile.h | 7 +-- 6 files changed, 103 insertions(+), 15 deletions(-) diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index bb351c0..66ef5ba 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -104,3 +104,60 @@ ManualIPAddress= [CoreRedirects] +ClassRedirects=(OldName="/Script/M4_CPP.M4_CentipedeController",NewName="/Script/M4_CPP.M4_CentipedeController") +[/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") + diff --git a/Source/M4_CPP/private/M4_Mushroom.cpp b/Source/M4_CPP/private/M4_Mushroom.cpp index 456a14f..ba7fde7 100644 --- a/Source/M4_CPP/private/M4_Mushroom.cpp +++ b/Source/M4_CPP/private/M4_Mushroom.cpp @@ -31,12 +31,26 @@ AM4_Mushroom::AM4_Mushroom() const FVector2D MushroomScale = FVector2D(0.3f, 0.25f); GetStaticMeshComponent()->SetRelativeScale3D(FVector(1.f, 0.45f, 0.20f)); - // Set collision profile to overlap all - GetStaticMeshComponent()->SetCollisionProfileName(TEXT("OverlapAll")); + // Set collision profile to block all + GetStaticMeshComponent()->SetCollisionProfileName(TEXT("BlockAll")); } void AM4_Mushroom::BeginPlay() { + MushLife = 3; + DestructionHit = 0; Super::BeginPlay(); +} + +void AM4_Mushroom::OnHit(UPrimitiveComponent* HitComp,AActor* OtherActor,UPrimitiveComponent* OtherComp,FVector NormalImpulse,const FHitResult& Hit) +{ + if (OtherActor != this) + { + DestructionHit++; + if (DestructionHit == MushLife) + { + Destroy(); + } + } } \ No newline at end of file diff --git a/Source/M4_CPP/private/M4_PlayerPawn.cpp b/Source/M4_CPP/private/M4_PlayerPawn.cpp index a79344f..22bf50a 100644 --- a/Source/M4_CPP/private/M4_PlayerPawn.cpp +++ b/Source/M4_CPP/private/M4_PlayerPawn.cpp @@ -42,7 +42,7 @@ AM4_PlayerPawn::AM4_PlayerPawn() void AM4_PlayerPawn::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) @@ -90,7 +90,7 @@ void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst) { FActorSpawnParameters SpawnParams; SpawnParams.Owner = this; - const FVector InitialLocation = FVector(0, GetActorLocation().Y, GetActorLocation().Z); + const FVector InitialLocation = FVector(-400.f, GetActorLocation().Y, GetActorLocation().Z); const FRotator InitialRotation = FRotator(0.f); AM4_Projectile* Projectile = World->SpawnActor(Proj, InitialLocation, InitialRotation, SpawnParams); if (Projectile) diff --git a/Source/M4_CPP/private/M4_Projectile.cpp b/Source/M4_CPP/private/M4_Projectile.cpp index a312406..0252839 100644 --- a/Source/M4_CPP/private/M4_Projectile.cpp +++ b/Source/M4_CPP/private/M4_Projectile.cpp @@ -1,6 +1,7 @@ #include "M4_Projectile.h" #include "Components/MeshComponent.h" #include "M4_Gamemode.h" +#include "M4_Mushroom.h" // Sets default values AM4_Projectile::AM4_Projectile() @@ -11,7 +12,7 @@ AM4_Projectile::AM4_Projectile() { RootComponent = CreateDefaultSubobject(TEXT("ProjectileSceneComponent")); ProjectileMeshComponent = CreateDefaultSubobject(TEXT("ProjectileMeshComponent")); - ProjectileMeshComponent->SetupAttachment(RootComponent); + ProjectileMeshComponent->SetupAttachment(RootComponent); static ConstructorHelpers::FObjectFinder Mesh(TEXT("/Game/CTP/04_Mesh/SM_Projectile.SM_Projectile")); if(Mesh.Succeeded()) @@ -26,7 +27,7 @@ AM4_Projectile::AM4_Projectile() } ProjectileMeshComponent->SetMaterial(0, ProjectileMat); - ProjectileMeshComponent->SetRelativeScale3D(FVector(.3f, .3f, .35f)); + ProjectileMeshComponent->SetRelativeScale3D(FVector(.8f, .3f, .35f)); ProjectileMeshComponent->SetMobility(EComponentMobility::Movable); ProjectileMeshComponent->SetRelativeLocation(InitialLoc); @@ -45,6 +46,7 @@ AM4_Projectile::AM4_Projectile() { CollisionComp = CreateDefaultSubobject(TEXT("MeshComponent")); } + } ///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. @@ -56,17 +58,26 @@ void AM4_Projectile::BeginPlay() InitialLoc = GetActorLocation(); } -void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit) +void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) { - + if (OtherActor && OtherActor != this && OtherComp != nullptr) + { + AM4_Mushroom* Mushroom = Cast(OtherActor); + if (Mushroom) + { + Mushroom->OnHit(HitComp,OtherActor,OtherComp,NormalImpulse,Hit); + } + + Destroy(); + } } void AM4_Projectile::FireInDir(const FVector& ShootDir) { SetActorLocation(InitialLoc); - ProjectileMovementComponent->Velocity.Z = -1 * ((ShootDir.Z + 390.f) * ProjectileMovementComponent->InitialSpeed); + ProjectileMovementComponent->Velocity.Z = -1 * ((ShootDir.Z + 380.f) * ProjectileMovementComponent->InitialSpeed); // ProjectileMovementComponent->Velocity.Y = InitialLoc.Y; - // ProjectileMovementComponent->Velocity.X = InitialLoc.X; + ProjectileMovementComponent->Velocity.X = 0.f; } // Called every frame diff --git a/Source/M4_CPP/public/M4_Mushroom.h b/Source/M4_CPP/public/M4_Mushroom.h index 7dbe9ce..2ed4c41 100644 --- a/Source/M4_CPP/public/M4_Mushroom.h +++ b/Source/M4_CPP/public/M4_Mushroom.h @@ -13,9 +13,14 @@ class M4_CPP_API AM4_Mushroom : public AStaticMeshActor GENERATED_BODY() public: - // Sets default values for this pawn's properties AM4_Mushroom(); - + + int MushLife; + int DestructionHit = 0; + + UFUNCTION() + void OnHit(UPrimitiveComponent* HitComp,AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse,const FHitResult& Hit); + protected: virtual void BeginPlay() override; }; diff --git a/Source/M4_CPP/public/M4_Projectile.h b/Source/M4_CPP/public/M4_Projectile.h index ee8b780..3d0059f 100644 --- a/Source/M4_CPP/public/M4_Projectile.h +++ b/Source/M4_CPP/public/M4_Projectile.h @@ -20,7 +20,7 @@ public: virtual void Tick( float DeltaTime ) override; virtual void BeginPlay() override; - float Speed = 1.f; + bool CollisionCheck = false; FVector InitialLoc; FVector NewLoc; @@ -35,7 +35,8 @@ public: UPROPERTY(VisibleDefaultsOnly, Category = Projectile) UMaterialInstanceDynamic* ProjectileMat; - - void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit); + + UFUNCTION() + void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit); void FireInDir(const FVector& ShootDir); };