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);
|
||||
|
||||
AM4_Projectile* Projectile = World->SpawnActor<AM4_Projectile>(Proj, InitialLocation, InitialRotation, SpawnParams);
|
||||
FVector LaunchDirection = FVector(InitialLocation);
|
||||
|
||||
if (Projectile)
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, TEXT("Spell Casted!"));
|
||||
//FVector LaunchDirection = FVector(InitialLocation);
|
||||
/*if (Projectile)
|
||||
{
|
||||
Projectile->ShootDirection(LaunchDirection);
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, TEXT("Spell Casted!"));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Sets default values
|
||||
AM4_Projectile::AM4_Projectile()
|
||||
{
|
||||
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
if(!RootComponent)
|
||||
@@ -19,19 +20,7 @@ AM4_Projectile::AM4_Projectile()
|
||||
RootComponent = CollisionComp;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
if (!ProjectileMeshComponent)
|
||||
{
|
||||
ProjectileMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMeshComponent"));
|
||||
|
||||
@@ -53,26 +42,34 @@ AM4_Projectile::AM4_Projectile()
|
||||
ProjectileMeshComponent->SetupAttachment(RootComponent);
|
||||
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Using the Wand!"));
|
||||
|
||||
///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
|
||||
}
|
||||
}
|
||||
|
||||
//InitialLifeSpan = 2.f;
|
||||
|
||||
}
|
||||
|
||||
void AM4_Projectile::ShootDirection(const FVector& ShootDir)
|
||||
/*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)
|
||||
{
|
||||
ProjectileMovementComponent->Velocity = -1.f * (ShootDir * ProjectileMovementComponent->InitialSpeed);
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
void AM4_Projectile::Tick( float 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()
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Category = Movement)
|
||||
UProjectileMovementComponent* ProjectileMovementComponent;
|
||||
|
||||
public:
|
||||
|
||||
AM4_Projectile();
|
||||
|
||||
virtual void Tick( float DeltaTime ) override;
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
float Speed = 1.f;
|
||||
FVector InitialLoc;
|
||||
FVector NewLoc;
|
||||
|
||||
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||
UMeshComponent* CollisionComp;
|
||||
@@ -28,7 +30,7 @@ public:
|
||||
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||
UStaticMeshComponent* ProjectileMeshComponent;
|
||||
|
||||
UPROPERTY(VisibleDefaultsOnly, Category = Movement)
|
||||
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||
UMaterialInstanceDynamic* ProjectileMat;
|
||||
|
||||
void ShootDirection(const FVector& ShootDir);
|
||||
|
||||
Reference in New Issue
Block a user