Minor - Nouveau comportement pour la Balle
La Balle devrait pouvoir directement se déplacer et avoir son mesh qui spawne aussi
This commit is contained in:
@@ -97,13 +97,12 @@ void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst)
|
|||||||
const FRotator InitialRotation = FRotator(0.f);
|
const FRotator InitialRotation = FRotator(0.f);
|
||||||
|
|
||||||
AM4_Projectile* Projectile = World->SpawnActor<AM4_Projectile>(Proj, InitialLocation, InitialRotation, SpawnParams);
|
AM4_Projectile* Projectile = World->SpawnActor<AM4_Projectile>(Proj, InitialLocation, InitialRotation, SpawnParams);
|
||||||
FVector LaunchDirection = FVector(InitialLocation);
|
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, TEXT("Spell Casted!"));
|
||||||
|
//FVector LaunchDirection = FVector(InitialLocation);
|
||||||
if (Projectile)
|
/*if (Projectile)
|
||||||
{
|
{
|
||||||
Projectile->ShootDirection(LaunchDirection);
|
Projectile->ShootDirection(LaunchDirection);
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, TEXT("Spell Casted!"));
|
}*/
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
// Sets default values
|
// Sets default values
|
||||||
AM4_Projectile::AM4_Projectile()
|
AM4_Projectile::AM4_Projectile()
|
||||||
{
|
{
|
||||||
|
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
|
||||||
if(!RootComponent)
|
if(!RootComponent)
|
||||||
@@ -19,19 +20,7 @@ AM4_Projectile::AM4_Projectile()
|
|||||||
RootComponent = CollisionComp;
|
RootComponent = CollisionComp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ProjectileMeshComponent)
|
||||||
if(!ProjectileMovementComponent)
|
|
||||||
{
|
|
||||||
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComponent"));
|
|
||||||
ProjectileMovementComponent->SetUpdatedComponent(CollisionComp);
|
|
||||||
ProjectileMovementComponent->InitialSpeed = 10.0f;
|
|
||||||
ProjectileMovementComponent->MaxSpeed = 10.0f;
|
|
||||||
ProjectileMovementComponent->bRotationFollowsVelocity = false;
|
|
||||||
ProjectileMovementComponent->bShouldBounce = false;
|
|
||||||
ProjectileMovementComponent->ProjectileGravityScale = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ProjectileMovementComponent)
|
|
||||||
{
|
{
|
||||||
ProjectileMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMeshComponent"));
|
ProjectileMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMeshComponent"));
|
||||||
|
|
||||||
@@ -53,26 +42,34 @@ AM4_Projectile::AM4_Projectile()
|
|||||||
ProjectileMeshComponent->SetupAttachment(RootComponent);
|
ProjectileMeshComponent->SetupAttachment(RootComponent);
|
||||||
|
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Using the Wand!"));
|
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Using the Wand!"));
|
||||||
}
|
|
||||||
|
|
||||||
//InitialLifeSpan = 2.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::ShootDirection(const FVector& ShootDir)
|
/*void AM4_Projectile::ShootDirection(const FVector& ShootDir)
|
||||||
{
|
{
|
||||||
ProjectileMovementComponent->Velocity = -1.f * (ShootDir * ProjectileMovementComponent->InitialSpeed);
|
FVector Dir = -1.f *(ShootDir * Speed);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
void AM4_Projectile::OnHit(
|
||||||
|
* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector Impulse, const FHitResult& Hit)
|
void AM4_Projectile::BeginPlay()
|
||||||
{
|
{
|
||||||
//OtherComp->AddImpulseAtLocation(GetVelocity() * BulletSpeed, GetActorLocation());
|
Super::BeginPlay();
|
||||||
|
InitialLoc = GetActorLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
void AM4_Projectile::Tick( float DeltaTime )
|
void AM4_Projectile::Tick( float DeltaTime )
|
||||||
{
|
{
|
||||||
Super::Tick( DeltaTime );
|
Super::Tick( DeltaTime);
|
||||||
|
//NewLoc = GetActorLocation() + FVector(0.f, InitialLoc.Y * Speed * DeltaTime, InitialLoc.Z * Speed * DeltaTime);
|
||||||
}
|
}
|
||||||
@@ -13,14 +13,16 @@ class M4_CPP_API AM4_Projectile : public AActor
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, Category = Movement)
|
|
||||||
UProjectileMovementComponent* ProjectileMovementComponent;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AM4_Projectile();
|
AM4_Projectile();
|
||||||
|
|
||||||
virtual void Tick( float DeltaTime ) override;
|
virtual void Tick( float DeltaTime ) override;
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
float Speed = 1.f;
|
||||||
|
FVector InitialLoc;
|
||||||
|
FVector NewLoc;
|
||||||
|
|
||||||
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||||
UMeshComponent* CollisionComp;
|
UMeshComponent* CollisionComp;
|
||||||
@@ -28,7 +30,7 @@ public:
|
|||||||
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||||
UStaticMeshComponent* ProjectileMeshComponent;
|
UStaticMeshComponent* ProjectileMeshComponent;
|
||||||
|
|
||||||
UPROPERTY(VisibleDefaultsOnly, Category = Movement)
|
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||||
UMaterialInstanceDynamic* ProjectileMat;
|
UMaterialInstanceDynamic* ProjectileMat;
|
||||||
|
|
||||||
void ShootDirection(const FVector& ShootDir);
|
void ShootDirection(const FVector& ShootDir);
|
||||||
|
|||||||
Reference in New Issue
Block a user