
void AItem::PostInitializeComponents()
{
Super::PostInitializeComponents();
UE_LOG(LogSparta, Warning, TEXT("%s PostInitializeComponents"), *GetName());
}
void AItem::BeginPlay()
{
Super::BeginPlay();
UE_LOG(LogSparta, Warning, TEXT("%s BeginPlay"), *GetName());
}
void AItem::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// 틱함수는 로그를 넣지않는다.
}
void AItem::Destroyed()
{
UE_LOG(LogSparta, Warning, TEXT("%s Destroyed"), *GetName());
Super::Destroyed();
}
void AItem::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
Super::EndPlay(EndPlayReason);
UE_LOG(LogSparta, Warning, TEXT("%s EndPlay"), *GetName());
}
void AItem::BeginPlay()
{
Super::BeginPlay();
SetActorLocation(FVector(300.0f, 200.0f, 100.0f));
SetActorRotation(FRotator(0.0f, 90.0f, 0.0f));
// pitch, yaw, roll
// y축, z축, x축
SetActorScale3D(FVector(2.0f));
FVector NewLocation(300.0f, 200.0f, 100.0f);
FVector NewRotation(0.0f, 90.0f, 0.0f);
FVector NewScale(2.0f);
FTransform NewTransform(NewRotation, NewLocation, NewScale);
setActorTransform(NewTransform);
}
void AItem::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (!FMath::IsNearlyZero(RotationSpeed))
{
AddActorLocalRotation(FRotator(0.0f, RotationSpeed * DeltaTime, 0.0f));
}
}
빌드가 필요가없다.
프로그래머가 아닌분들도 쉽게 로직을 이해할 수 있다.
디자이너, 기획자가 사용
UI, 시네마틱, 애니메이션 연출, 프로토타이핑 등에 사용
난이도가 있다.
엔진자체가 C++로 만들어져있기 때문에 엔진의 거의 모든 부분을 바꾸고 속도최적화등 커스터마이징을 할 수 있다.
서드파티 라이브러리같은것들을 사용할 수 있다.
대규모작업에서 체계적으로 관리가능
메모리관리 직접 가능
하지만 빌드하는 과정이 번거롭다.
개발자
복잡한 계산, 게임 로직
#include "Item.generated.h" // 리플렉션 시스템을 위해 필요, 꼭 include의 가장 마지막에 위치
UCLASS() // 클래스를 리플렉션 시스템에 등록
class NBC1_API AItem : public AActor
{
GENERATED_BODY() // 리플렉션 시스템에 등록하기 위한 코드
public:
AItem();
protected:
UPROPERTY() // 리플렉션에 아래 멤버변수를 리플렉션에 등록
USceneComponent* SceneRoot;
UPROPERTY()
UStaticMeshComponent* StaticMeshComp;
UPROPERTY()
float RotationSpeed;
virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;
};
// 두번째인자, 블루프린트에서 노드를 만들 때
Object의 개념
Actor의 개념
// Fill out your copyright notice in the Description page of Project Settings.
#include "Item.h"
#include "Components/AudioComponent.h"
DEFINE_LOG_CATEGORY(JongKyu);
AItem::AItem()
{
SceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
SetRootComponent(SceneRoot);
StaticMeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMesh"));
StaticMeshComp->SetupAttachment(SceneRoot);
static ConstructorHelpers::FObjectFinder<UStaticMesh> MeshAsset(TEXT("/Game/Resources/Props/SM_Chair.SM_Chair"));
if (MeshAsset.Succeeded())
{
StaticMeshComp->SetStaticMesh(MeshAsset.Object);
}
static ConstructorHelpers::FObjectFinder<UMaterial> MaterialAsset(TEXT("/Game/Resources/Materials/M_Metal_Gold.M_Metal_Gold"));
if (MaterialAsset.Succeeded())
{
StaticMeshComp->SetMaterial(0, MaterialAsset.Object);
}
StaticMeshAudio = CreateDefaultSubobject<UAudioComponent>(TEXT("Audio"));
StaticMeshAudio->SetupAttachment(SceneRoot);
static ConstructorHelpers::FObjectFinder<USoundBase> AudioAsset(TEXT("/Game/Resources/Audio/Starter_Wind05.Starter_Wind05"));
if (AudioAsset.Succeeded())
{
StaticMeshAudio->SetSound(AudioAsset.Object);
}
}
void AItem::BeginPlay()
{
Super::BeginPlay();
UE_LOG(JongKyu, Warning, TEXT("%s BeginPlay"), *GetName());
}
void AItem::Tick(float deltaTime)
{
Super::Tick(deltaTime);
UE_LOG(JongKyu, Warning, TEXT("성능저하 실험입니다."));
}


#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
bool algo(unordered_map<int, int>& um, vector<int>& reserve, int l){
auto findk3 = um.find(l);
if (findk3 == um.end()){
auto it3 = find(reserve.begin(), reserve.end(), l);
if (it3 != reserve.end()){
um.insert({l, 1});
return true;
}
}
return false;
}
int solution(int n, vector<int> lost, vector<int> reserve) {
int answer = 0;
unordered_map<int, int> um;
sort(lost.begin(), lost.end());
for (int r : reserve){
auto findk3 = um.find(r);
if (findk3 == um.end()){
auto it3 = find(lost.begin(), lost.end(), r);
if (it3 != lost.end()){
um.insert({r, 1});
}
}
}
for (int l : lost){
if (um.find(l) != um.end()){
continue;
}
if (algo(um, reserve, l)){
continue;
}
if (algo(um, reserve, l-1)){
continue;
}
if (algo(um, reserve, l+1)){
continue;
}
answer++;
}
return n-answer;
}
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(int n, vector<int> lost, vector<int> reserve) {
int answer = 0;
sort(lost.begin(), lost.end());
for (int& l : lost){
auto it = find(reserve.begin(), reserve.end(), l);
if (it != reserve.end()){
reserve.erase(it);
l = 0;
}
}
for (int l : lost){
if (l == 0){
continue;
}
auto it = find(reserve.begin(), reserve.end(), l-1);
if (it != reserve.end()){
reserve.erase(it);
continue;
}
auto it2 = find(reserve.begin(), reserve.end(), l+1);
if (it2 != reserve.end()){
reserve.erase(it2);
continue;
}
answer++;
}
return n-answer;
}
for (int& l : lost){
auto it = find(reserve.begin(), reserve.end(), l);
if (it != reserve.end()){
reserve.erase(it);
l = 0;
}
}
#include <string>
#include <vector>
using namespace std;
int solution(string s) {
int answer = 0;
char prev = '\0';
int count = 0;
int otherCount = 0;
int index = 0;
for (int i = 0; i < s.length(); i++){
if (prev == '\0'){
prev = s[i];
count++;
} else {
if (prev != s[i]){
otherCount++;
if (count == otherCount){
count = 0;
otherCount = 0;
prev = '\0';
answer++;
index = i;
}
} else {
count++;
}
}
}
if (count != 0){
answer++;
}
return answer;
}
PostInitializeComponents / BeginPlay / Tick / EndPlay / Destroyed 타이밍을 로그로 확인해봄.SetActorLocation/Rotation/Scale, 그리고 FTransform으로 한 번에 세팅하는 방식 복습.PrimaryActorTick.bCanEverTick = true;를 켜야 Tick이 호출됨.UAudioComponent 붙이기/사운드 세팅하면서 헤더 include(incomplete type), USoundBase로 에셋 로드 후 SetSound()로 연결하는 흐름을 익힘.unordered_map으로 “사용 처리”를 했지만, 나중엔 find로 iterator 얻어서 reserve.erase(it)로 지우는 방식이 더 직관적이라는 걸 알게 됨.int& l처럼 참조로 받으면 원본 벡터 값을 바꿀 수 있음char prev = '\0'를 두고, 기준 문자 카운트와 다른 문자 카운트를 맞추는 방식으로 풀이.