Minor - Sprite du Projectile
Le modèle 3D du projectile apparait enfin, maintenant, il faut que je puisse donner au modèle la bonne position de départ.
This commit is contained in:
@@ -87,16 +87,17 @@ void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst)
|
||||
if (Proj)
|
||||
{
|
||||
UWorld* World = GetWorld();
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Using the Wand!"));
|
||||
//GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Using the Wand!"));
|
||||
|
||||
if (World)
|
||||
{
|
||||
FActorSpawnParameters SpawnParams;
|
||||
SpawnParams.Owner = this;
|
||||
const FVector InitialLocation = FVector(0.0f, GetActorLocation().Y, GetActorLocation().Z);
|
||||
const FVector InitialLocation = FVector(GetActorLocation().X, GetActorLocation().Y, GetActorLocation().Z);
|
||||
const FRotator InitialRotation = FRotator(0.f);
|
||||
|
||||
AM4_Projectile* Projectile = World->SpawnActor<AM4_Projectile>(Proj, InitialLocation, FRotator(), SpawnParams);
|
||||
FVector LaunchDirection = FVector(0.0f, InitialLocation.Y + 1.f,InitialLocation.Z);
|
||||
AM4_Projectile* Projectile = World->SpawnActor<AM4_Projectile>(Proj, InitialLocation, InitialRotation, SpawnParams);
|
||||
FVector LaunchDirection = FVector(InitialLocation);
|
||||
|
||||
if (Projectile)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "GameFramework/ProjectileMovementComponent.h"
|
||||
#include "Components/MeshComponent.h"
|
||||
|
||||
|
||||
// Sets default values
|
||||
AM4_Projectile::AM4_Projectile()
|
||||
{
|
||||
@@ -23,39 +24,45 @@ AM4_Projectile::AM4_Projectile()
|
||||
{
|
||||
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComponent"));
|
||||
ProjectileMovementComponent->SetUpdatedComponent(CollisionComp);
|
||||
ProjectileMovementComponent->InitialSpeed = 700.0f;
|
||||
ProjectileMovementComponent->MaxSpeed = 700.0f;
|
||||
ProjectileMovementComponent->bRotationFollowsVelocity = true;
|
||||
ProjectileMovementComponent->InitialSpeed = 10.0f;
|
||||
ProjectileMovementComponent->MaxSpeed = 10.0f;
|
||||
ProjectileMovementComponent->bRotationFollowsVelocity = false;
|
||||
ProjectileMovementComponent->bShouldBounce = false;
|
||||
ProjectileMovementComponent->ProjectileGravityScale = 0.0f;
|
||||
}
|
||||
|
||||
if (!ProjectileMovementComponent)
|
||||
if (ProjectileMovementComponent)
|
||||
{
|
||||
ProjectileMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMeshComponent"));
|
||||
|
||||
static ConstructorHelpers::FObjectFinder<UStaticMesh>Mesh(TEXT("'/Script/Engine.StaticMesh'/Game/CTP/04_Mesh/SM_Projectile.SM_Projectile'"));
|
||||
static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("/Game/CTP/04_Mesh/SM_Projectile.SM_Projectile"));
|
||||
if(Mesh.Succeeded())
|
||||
{
|
||||
ProjectileMeshComponent->SetStaticMesh(Mesh.Object);
|
||||
}
|
||||
|
||||
static ConstructorHelpers::FObjectFinder<UMaterial>Material(TEXT("'/Script/Engine.Material'/Game/CTP/05_Material/M_Player.M_Player'"));
|
||||
static ConstructorHelpers::FObjectFinder<UMaterial> Material(TEXT("/Game/CTP/05_Material/M_Player.M_Player"));
|
||||
if (Material.Succeeded())
|
||||
{
|
||||
ProjectileMat = UMaterialInstanceDynamic::Create(Material.Object, ProjectileMeshComponent);
|
||||
}
|
||||
|
||||
ProjectileMeshComponent->SetMaterial(0, ProjectileMat);
|
||||
ProjectileMeshComponent->SetRelativeScale3D(FVector(.2f, .2f, .2f));
|
||||
ProjectileMeshComponent->SetRelativeScale3D(FVector(.2f, .2f, .25f));
|
||||
ProjectileMeshComponent->SetMobility(EComponentMobility::Movable);
|
||||
ProjectileMeshComponent->SetupAttachment(RootComponent);
|
||||
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Using the Wand!"));
|
||||
}
|
||||
|
||||
//InitialLifeSpan = 2.f;
|
||||
|
||||
}
|
||||
|
||||
void AM4_Projectile::ShootDirection(const FVector& ShootDir)
|
||||
{
|
||||
ProjectileMovementComponent->Velocity = ShootDir * ProjectileMovementComponent->InitialSpeed;
|
||||
ProjectileMovementComponent->Velocity = -1.f * (ShootDir * ProjectileMovementComponent->InitialSpeed);
|
||||
|
||||
}
|
||||
|
||||
void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector Impulse, const FHitResult& Hit)
|
||||
|
||||
@@ -14,8 +14,7 @@ class M4_CPP_API AM4_Projectile : public AActor
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Category = Movement)
|
||||
UProjectileMovementComponent* ProjectileMovementComponent;
|
||||
|
||||
UProjectileMovementComponent* ProjectileMovementComponent;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user