- x, y, z 축 좌표에 대한 정보를 가지고 있는 구조체
FVector(double x, double y, double z)
FVector v;
v.Length();
v.Normalize();
- 특정 방향으로 액터를 이동시키는 방법
float Speed = 50.0f;
float Distance = DeltaTime * Speed;
FVector Location = GetActorLocation();
FVector NewLocation= Location * FVector::ForwardVector * Distance;;
AddActorWorldOffset(FVector::ForwardVector * Distance);
- 특정 Target을 따라가도록 만들어보자
UPROPERTY(EditAnywhere, Category = Battle)
TObjectPtr<class AActor> Target;
float Speed = 50.0f;
float Distance = DeltaTime * Speed;
FVector Location = GetActorLocation();
FVector DirectionVector = Target->GetActorLocation() - GetActorLocation();
DirectionVector.Normalize();
FVector NewLocation= Location * DirectionVector * Distance;;
AddActorWorldOffset(DirectionVector*Speed);
- 현재 맵에 있는 특정 Actor를 찾는 방법
Target = UGameplayStatics::GetActorOfClass(GetWorld(), ARActor::StaticClass());
TArray<AActor*> Actors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ARActor::StaticClass(), OUT Actors);
UGameplayStatics::GetAllActorsWithTag(GetWorld(), TEXT("R"), OUT Actors);
if(Actors.Num() > 0)
{
}