Revert "Minor - Petit changement pour le spawn des balles"

This reverts commit 406bafff0a.
This commit is contained in:
NisemonoQ
2025-10-30 22:44:26 +01:00
parent 406bafff0a
commit ed5475299e
4 changed files with 17 additions and 27 deletions

View File

@@ -1 +0,0 @@
M4_CPP

View File

@@ -97,7 +97,6 @@ void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst)
const FRotator InitialRotation = FRotator(0.f);
AM4_Projectile* Projectile = World->SpawnActor<AM4_Projectile>(Proj, InitialLocation, InitialRotation, SpawnParams);
FVector LaunchDirection = FVector(InitialLocation);
if (Projectile)

View File

@@ -6,7 +6,6 @@
// Sets default values
AM4_Projectile::AM4_Projectile()
{
PrimaryActorTick.bCanEverTick = true;
if(!RootComponent)
@@ -20,6 +19,7 @@ AM4_Projectile::AM4_Projectile()
RootComponent = CollisionComp;
}
if(!ProjectileMovementComponent)
{
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComponent"));
@@ -29,20 +29,17 @@ AM4_Projectile::AM4_Projectile()
ProjectileMovementComponent->bRotationFollowsVelocity = false;
ProjectileMovementComponent->bShouldBounce = false;
ProjectileMovementComponent->ProjectileGravityScale = 0.0f;
LastMove = GetActorLocation();
}
if (!ProjectileMeshComponent)
if (ProjectileMovementComponent)
{
ProjectileMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMeshComponent"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("/Game/CTP/04_Mesh/SM_Projectile.SM_Projectile"));
if(Mesh.Succeeded())
{
ProjectileMeshComponent->SetStaticMesh(Mesh.Object);
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Using the Wand!"));
}
if(Mesh.Succeeded())
{
ProjectileMeshComponent->SetStaticMesh(Mesh.Object);
}
static ConstructorHelpers::FObjectFinder<UMaterial> Material(TEXT("/Game/CTP/05_Material/M_Player.M_Player"));
if (Material.Succeeded())
@@ -52,24 +49,20 @@ AM4_Projectile::AM4_Projectile()
ProjectileMeshComponent->SetMaterial(0, ProjectileMat);
ProjectileMeshComponent->SetRelativeScale3D(FVector(.2f, .2f, .25f));
//ProjectileMeshComponent->SetRelativeLocation();
ProjectileMeshComponent->SetMobility(EComponentMobility::Movable);
ProjectileMeshComponent->SetupAttachment(RootComponent);
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Using the Wand!"));
}
}
//InitialLifeSpan = 2.f;
void AM4_Projectile::BeginPlay()
{
Super::BeginPlay();
LastMove = GetActorLocation();
SetActorLocation(LastMove);
}
void AM4_Projectile::ShootDirection(const FVector& ShootDir)
{
ProjectileMovementComponent->Velocity = -1.f * (ShootDir * ProjectileMovementComponent->InitialSpeed);
}
void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector Impulse, const FHitResult& Hit)
@@ -81,4 +74,5 @@ void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPr
void AM4_Projectile::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}

View File

@@ -13,26 +13,24 @@ class M4_CPP_API AM4_Projectile : public AActor
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, Category = Movement)
UProjectileMovementComponent* ProjectileMovementComponent;
public:
AM4_Projectile();
virtual void BeginPlay() override;
virtual void Tick( float DeltaTime ) override;
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
UMeshComponent* CollisionComp;
UPROPERTY(VisibleAnywhere, Category = Movement)
UProjectileMovementComponent* ProjectileMovementComponent;
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
UStaticMeshComponent* ProjectileMeshComponent;
UPROPERTY(VisibleDefaultsOnly, Category = Movement)
UMaterialInstanceDynamic* ProjectileMat;
FVector LastMove = FVector::ZeroVector;
void ShootDirection(const FVector& ShootDir);
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit);