From 9ddc2fdbed288609bffcc2671ff7d2bfe5670630 Mon Sep 17 00:00:00 2001 From: NisemonoQ Date: Fri, 31 Oct 2025 17:54:49 +0100 Subject: [PATCH] Minor - Ajustement sur la balle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le sprite devrait apparaitre et se déplacer avec tout l'objet + la balle. --- Source/M4_CPP/private/M4_PlayerPawn.cpp | 8 -------- Source/M4_CPP/private/M4_Projectile.cpp | 24 ++++++++---------------- Source/M4_CPP/public/M4_Projectile.h | 6 +----- 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/Source/M4_CPP/private/M4_PlayerPawn.cpp b/Source/M4_CPP/private/M4_PlayerPawn.cpp index 884f3cc..4cb925d 100644 --- a/Source/M4_CPP/private/M4_PlayerPawn.cpp +++ b/Source/M4_CPP/private/M4_PlayerPawn.cpp @@ -3,8 +3,6 @@ #include "M4_Gamemode.h" #include "M4_Projectile.h" #include "GameFramework/PlayerController.h" -#include "Kismet/KismetMathLibrary.h" -#include "Camera/CameraComponent.h" AM4_PlayerPawn::AM4_PlayerPawn() { @@ -98,12 +96,6 @@ void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst) AM4_Projectile* Projectile = World->SpawnActor(Proj, InitialLocation, InitialRotation, SpawnParams); GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, TEXT("Spell Casted!")); - //FVector LaunchDirection = FVector(InitialLocation); - /*if (Projectile) - { - Projectile->ShootDirection(LaunchDirection); - }*/ } - } }; diff --git a/Source/M4_CPP/private/M4_Projectile.cpp b/Source/M4_CPP/private/M4_Projectile.cpp index 4780997..7a6e987 100644 --- a/Source/M4_CPP/private/M4_Projectile.cpp +++ b/Source/M4_CPP/private/M4_Projectile.cpp @@ -1,12 +1,10 @@ #include "M4_Projectile.h" -#include "GameFramework/ProjectileMovementComponent.h" #include "Components/MeshComponent.h" - +#include "M4_Gamemode.h" // Sets default values AM4_Projectile::AM4_Projectile() { - PrimaryActorTick.bCanEverTick = true; if(!RootComponent) @@ -49,27 +47,21 @@ AM4_Projectile::AM4_Projectile() } } -/*void AM4_Projectile::ShootDirection(const FVector& ShootDir) -{ - FVector Dir = -1.f *(ShootDir * Speed); -}*/ - - -void AM4_Projectile::OnHit( -* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit) -{ - -} void AM4_Projectile::BeginPlay() { Super::BeginPlay(); InitialLoc = GetActorLocation(); } - + +void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit) +{ + +} + // Called every frame void AM4_Projectile::Tick( float DeltaTime ) { Super::Tick( DeltaTime); - //NewLoc = GetActorLocation() + FVector(0.f, InitialLoc.Y * Speed * DeltaTime, InitialLoc.Z * Speed * DeltaTime); + NewLoc = InitialLoc + FVector(InitialLoc.X * Speed * DeltaTime, InitialLoc.Y * Speed * DeltaTime, InitialLoc.Z * Speed * DeltaTime); } \ No newline at end of file diff --git a/Source/M4_CPP/public/M4_Projectile.h b/Source/M4_CPP/public/M4_Projectile.h index 147d115..7d34b32 100644 --- a/Source/M4_CPP/public/M4_Projectile.h +++ b/Source/M4_CPP/public/M4_Projectile.h @@ -1,6 +1,4 @@ -#include "GameFramework/ProjectileMovementComponent.h" - -#pragma once +#pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" @@ -33,7 +31,5 @@ public: UPROPERTY(VisibleDefaultsOnly, Category = Projectile) UMaterialInstanceDynamic* ProjectileMat; - void ShootDirection(const FVector& ShootDir); void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit); - };