Tower 클래스
This commit is contained in:
parent
99c89a2ec2
commit
4aabcd0127
BIN
Content/Blueprints/Pawns/BP_PawnTurret.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Pawns/BP_PawnTurret.uasset
(Stored with Git LFS)
Binary file not shown.
27
Source/ToonTanks/Tower.cpp
Normal file
27
Source/ToonTanks/Tower.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Tower.h"
|
||||
#include "Tank.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
void ATower::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (Tank)
|
||||
{
|
||||
float Distance = FVector::Dist(this->GetActorLocation(), Tank->GetActorLocation());
|
||||
if (Distance <= FireRange)
|
||||
{
|
||||
RotateTurret(Tank->GetActorLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ATower::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
Tank = Cast<ATank>(UGameplayStatics::GetPlayerPawn(this, 0));
|
||||
}
|
32
Source/ToonTanks/Tower.h
Normal file
32
Source/ToonTanks/Tower.h
Normal file
@ -0,0 +1,32 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BasePawn.h"
|
||||
#include "Tower.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TOONTANKS_API ATower : public ABasePawn
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
private:
|
||||
|
||||
class ATank* Tank;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Rotate")
|
||||
float FireRange = 400;
|
||||
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user