diff --git a/.idea/.idea.M4_CPP.dir/.idea/.name b/.idea/.idea.M4_CPP.dir/.idea/.name deleted file mode 100644 index 4857ff5..0000000 --- a/.idea/.idea.M4_CPP.dir/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -M4_CPP \ No newline at end of file diff --git a/Source/M4_CPP/private/M4_PlayerPawn.cpp b/Source/M4_CPP/private/M4_PlayerPawn.cpp index 59c7b4a..d145f58 100644 --- a/Source/M4_CPP/private/M4_PlayerPawn.cpp +++ b/Source/M4_CPP/private/M4_PlayerPawn.cpp @@ -97,7 +97,6 @@ void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst) const FRotator InitialRotation = FRotator(0.f); AM4_Projectile* Projectile = World->SpawnActor(Proj, InitialLocation, InitialRotation, SpawnParams); - FVector LaunchDirection = FVector(InitialLocation); if (Projectile) diff --git a/Source/M4_CPP/private/M4_Projectile.cpp b/Source/M4_CPP/private/M4_Projectile.cpp index 8da97cd..c1920dc 100644 --- a/Source/M4_CPP/private/M4_Projectile.cpp +++ b/Source/M4_CPP/private/M4_Projectile.cpp @@ -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(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(TEXT("ProjectileMeshComponent")); static ConstructorHelpers::FObjectFinder 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 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!")); } -} - - -void AM4_Projectile::BeginPlay() -{ - Super::BeginPlay(); - LastMove = GetActorLocation(); - SetActorLocation(LastMove); + //InitialLifeSpan = 2.f; + } 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 ); + } \ 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 43a8936..6bafede 100644 --- a/Source/M4_CPP/public/M4_Projectile.h +++ b/Source/M4_CPP/public/M4_Projectile.h @@ -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);