Projectile 클래스

This commit is contained in:
강민제 2025-04-28 23:19:14 +09:00
parent b4912f8f3e
commit b1fcccad48
6 changed files with 72 additions and 2 deletions

BIN
Content/Blueprints/Actors/BP_Projectile.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -25,6 +25,7 @@ ABasePawn::ABasePawn()
ProjectileSpawnPoint->SetupAttachment(TurretMesh);
}
// Rotate Turret to Target Location
void ABasePawn::RotateTurret(FVector LookAtTarget)
{
FVector ToTarget = LookAtTarget - TurretMesh->GetComponentLocation();
@ -39,6 +40,7 @@ void ABasePawn::RotateTurret(FVector LookAtTarget)
);
}
// Fire Projectile at Projectile Spawn Point
void ABasePawn::Fire()
{
DrawDebugSphere(

View File

@ -21,15 +21,19 @@ protected:
void Fire();
private:
// CapsuleComponent for RootComponent
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess = "true"))
class UCapsuleComponent* CapsuleComp;
// Static Mesh Component of Tank Base
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess = "true"))
UStaticMeshComponent* BaseMesh;
// Static Mesh Component of Rotating part of Tank
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess = "true"))
UStaticMeshComponent* TurretMesh;
// Scene Component of Projectile Spawn Point
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess = "true"))
USceneComponent* ProjectileSpawnPoint;

View File

@ -0,0 +1,28 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Projectile.h"
// Sets default values
AProjectile::AProjectile()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
ProjectileMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Projectile Mesh"));
RootComponent = ProjectileMesh;
}
// Called when the game starts or when spawned
void AProjectile::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AProjectile::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}

View File

@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Projectile.generated.h"
UCLASS()
class TOONTANKS_API AProjectile : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AProjectile();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
private:
// Projectile Static Mesh Component
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess="true"))
UStaticMeshComponent* ProjectileMesh;
};

View File

@ -11,7 +11,6 @@ ATank::ATank()
{
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
SpringArm->SetupAttachment(RootComponent);
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(SpringArm);
}
@ -29,6 +28,7 @@ void ATank::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Rotate Tank to Mouse Pointer Location
if (PlayerControllerRef)
{
FHitResult HitResult;
@ -55,6 +55,7 @@ void ATank::BeginPlay()
PlayerControllerRef = Cast<APlayerController>(GetController());
}
// Move operation through W/S key
void ATank::Move(float Value)
{
FVector DeltaLocation = FVector::ZeroVector;
@ -63,6 +64,7 @@ void ATank::Move(float Value)
this->AddActorLocalOffset(DeltaLocation, true);
}
// Turn operation through A/D key
void ATank::Turn(float Value)
{
FRotator DeltaRotation = FRotator::ZeroRotator;