SYSTEM NOTICE

Auto translation by AI. Be sure, accuracy, nuances and authorial intent may not be fully reflected.
見出し画像

Unreal Engine Game Development Complete Textbook (Beginner to Intermediate) Summary.


Table of Contents

  1. Basic Knowledge of Unreal Engine

  2. Setting Up the Development Environment

  3. How to Use the Editor and Interface

  4. Introduction to Blueprint Programming

  5. Fundamentals of C++ Programming

  6. Basics of Level Design

  7. Materials and Textures

  8. Animation System

  9. UI/UX Design

  10. Performance Optimization

  11. Project Completion and Publishing


1. Basic Knowledge of Unreal Engine

What is Unreal Engine

Unreal Engine (UE) is a game engine developed by Epic Games. It is widely used for everything from professional-level game development to personal hobbies.

Key Features

  • Available for free: Free to use for commercial purposes up to a certain revenue threshold

  • High-quality graphics: Supports real-time ray tracing

  • Blueprint system: Create game logic without programming

  • C++ Support: Full-scale programming is also possible

  • Multi-platform: Supports PC, Console, Mobile, and VR

About Versions

The current latest version is UE5. This textbook mainly explains based on UE5, but the content can also be applied to UE4.


2. Development Environment Setup

System Requirements

Minimum Requirements:

  • OS: Windows 10 64-bit / macOS 10.14.6 / Ubuntu 18.04

  • Memory: 8GB RAM

  • Storage: 100GB or more of free space

  • GPU: DirectX 11 compatible

Recommended Requirements:

  • Memory: 32GB RAM

  • GPU: RTX 3070 or higher

  • SSD Storage

Installation Steps

  1. Download Epic Games Launcher

  2. Installing Unreal Engine

    • Select the "Unreal Engine" tab from the Launcher

    • Install the latest version (approx. 15GB)

  3. Additional Components

    • Visual Studio (for C++ development)

    • Android Studio (for mobile development)

Initial Launch and Project Creation

1. Epic Games Launcherを起動
2. 「Unreal Engine」→「起動」
3. 新規プロジェクト作成
   - テンプレート:Third Person(初心者推奨)
   - プロジェクト設定:Blueprint
   - プロジェクト名:MyFirstGame

3. Editor Usage and Interface

Main Interface

The Unreal Editor consists of the following main panels:

Viewport

  • 3D scene display and editing area

  • Camera movement: Right-click + WASD

  • Select object: Left-click

  • Multiple selection: Ctrl + Left-click

World Outliner

  • List of all objects in the level

  • Hierarchy management

  • Toggle object visibility

Details Panel

  • Display properties of the selected object

  • Parameter adjustment

  • Add/remove components

Content Browser

  • Asset Management

  • Storage locations for materials, textures, sounds, etc.

  • Import/Export functions

Basic Operations

Placing Objects

  1. Select an asset from the Content Browser

  2. Drag and drop into the viewport

  3. Adjust position, rotation, and scale with the Transform tool

Transform Tools

  • Move: W key

  • Rotate: E key

  • Scale: R key

Viewport Navigation

・カメラ移動:右クリック + WASD
・ズーム:マウスホイール
・パン:中クリック + ドラッグ
・フォーカス:F キー(選択オブジェクトにフォーカス)

4. Introduction to Blueprint Programming

What is Blueprint?

Blueprint is a visual scripting system. You can create game logic by connecting nodes without needing programming knowledge.

Types of Blueprints

  1. Level Blueprint: Logic specific to a particular level

  2. Class Blueprint: Reusable object classes

  3. Function Libraries: A collection of common functions

  4. Macros: A collection of complex node groups

Creating your first Blueprint

Example of creating a Player Controller

1. コンテンツブラウザで右クリック
2. 「Blueprint Class」を選択
3. 「Pawn」を選択
4. 名前を「MyPlayer」に設定

Basic movement system

Event Graph での設定:

Event BeginPlay
  └─ Set Max Walk Speed (600.0)

InputAxis MoveForward
  ├─ Scale: Axis Value
  └─ Add Movement Input
      └─ World Direction: (1, 0, 0)

InputAxis MoveRight  
  ├─ Scale: Axis Value
  └─ Add Movement Input
      └─ World Direction: (0, 1, 0)

Variables and events

Creating variables

1. Variables セクションで「+」をクリック
2. 変数名:Health
3. 変数タイプ:Float
4. デフォルト値:100.0
5. 「Instance Editable」にチェック(インスペクターで編集可能)

Custom events

Event Graph での Health システム例:

Custom Event: TakeDamage
  ├─ Input: Damage (Float)
  └─ Set Health
      ├─ Health - Damage
      └─ Branch
          ├─ Condition: Health <= 0
          ├─ True: Destroy Actor
          └─ False: Print String ("Health: " + Health)

Practical example: Simple jump function

InputAction Jump
  ├─ Pressed: Jump
  └─ Released: Stop Jumping

Component: Character Movement
  ├─ Jump Z Velocity: 600.0
  ├─ Air Control: 0.2
  └─ Gravity Scale: 1.75

5. C++ Programming Basics

Preparing the C++ development environment

Visual Studio configuration

1. Visual Studio 2019/2022をインストール
2. C++によるゲーム開発ワークロードを選択
3. Windows 10 SDKを含める

Creating a new C++ class

1. エディタで「Tools」→「New C++ Class」
2. 親クラスを選択(例:Pawn)
3. クラス名:MyPawn
4. 「Create Class」をクリック

Basic C++ class structure

Header file (MyPawn.h)

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "MyPawn.generated.h"

UCLASS()
class MYFIRSTGAME_API AMyPawn : public APawn
{
    GENERATED_BODY()

public:
    AMyPawn();

protected:
    virtual void BeginPlay() override;

    // コンポーネント
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
    class UStaticMeshComponent* MeshComponent;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
    class UCameraComponent* CameraComponent;

    // 変数
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
    float MovementSpeed = 100.0f;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health")
    float MaxHealth = 100.0f;

    UPROPERTY(BlueprintReadOnly, Category = "Health")
    float CurrentHealth;

public:
    virtual void Tick(float DeltaTime) override;
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

    // カスタム関数
    UFUNCTION(BlueprintCallable, Category = "Health")
    void TakeDamage(float DamageAmount);

    UFUNCTION(BlueprintPure, Category = "Health")
    float GetHealthPercentage() const;

private:
    void MoveForward(float Value);
    void MoveRight(float Value);
};

CPP file (MyPawn.cpp)

#include "MyPawn.h"
#include "Components/StaticMeshComponent.h"
#include "Camera/CameraComponent.h"
#include "Components/InputComponent.h"
#include "Engine/Engine.h"

AMyPawn::AMyPawn()
{
    PrimaryActorTick.bCanEverTick = true;

    // コンポーネントの作成
    MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));
    RootComponent = MeshComponent;

    CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
    CameraComponent->SetupAttachment(RootComponent);
    CameraComponent->SetRelativeLocation(FVector(-200.0f, 0.0f, 100.0f));

    // 初期化
    CurrentHealth = MaxHealth;
}

void AMyPawn::BeginPlay()
{
    Super::BeginPlay();
  
    UE_LOG(LogTemp, Warning, TEXT("MyPawn has spawned!"));
}

void AMyPawn::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
}

void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);

    // 入力バインディング
    PlayerInputComponent->BindAxis("MoveForward", this, &AMyPawn::MoveForward);
    PlayerInputComponent->BindAxis("MoveRight", this, &AMyPawn::MoveRight);
}

void AMyPawn::MoveForward(float Value)
{
    if (Value != 0.0f)
    {
        FVector Direction = GetActorForwardVector();
        AddMovementInput(Direction, Value);
    }
}

void AMyPawn::MoveRight(float Value)
{
    if (Value != 0.0f)
    {
        FVector Direction = GetActorRightVector();
        AddMovementInput(Direction, Value);
    }
}

void AMyPawn::TakeDamage(float DamageAmount)
{
    CurrentHealth = FMath::Clamp(CurrentHealth - DamageAmount, 0.0f, MaxHealth);
  
    if (CurrentHealth <= 0.0f)
    {
        UE_LOG(LogTemp, Warning, TEXT("Pawn destroyed!"));
        Destroy();
    }
    else
    {
        UE_LOG(LogTemp, Log, TEXT("Health: %f"), CurrentHealth);
    }
}

float AMyPawn::GetHealthPercentage() const
{
    return MaxHealth > 0.0f ? CurrentHealth / MaxHealth : 0.0f;
}

Integration between Blueprint and C++

Utilizing the UPROPERTY macro

// エディタで編集可能
UPROPERTY(EditAnywhere, Category = "Settings")
float JumpHeight = 500.0f;

// Blueprintから読み取り専用
UPROPERTY(BlueprintReadOnly, Category = "Status")
bool bIsAlive = true;

// Blueprintから読み書き可能
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory")
int32 ItemCount = 0;

Utilizing the UFUNCTION macro

// Blueprintから呼び出し可能
UFUNCTION(BlueprintCallable, Category = "Actions")
void PerformAction();

// Blueprintで実装可能(C++では空実装)
UFUNCTION(BlueprintImplementableEvent, Category = "Events")
void OnItemCollected();

// C++とBlueprint両方で実装可能
UFUNCTION(BlueprintnativeEvent, Category = "Events")
void OnDamageReceived(float Damage);
virtual void OnDamageReceived_Implementation(float Damage);

6. Basics of level design

Concepts of level design

Basic Principles

  1. Player Guidance: Design that allows for natural game progression

  2. Visual Hierarchy: Making important elements stand out

  3. Balance: Proper placement of difficulty and rewards

  4. Consistency: Unified art style and rules

Geometry and BSP

Using BSP (Binary Space Partitioning)

1. モードパネルで「Geometry」モードを選択
2. BSPブラシを選択(Box、Cylinder、Sphere等)
3. ビューポートにドラッグ&ドロップ
4. スケールや形状を調整

Basic level creation steps

1. 床の作成:Box BSPを薄く伸ばして床にする
2. 壁の作成:縦長のBox BSPで境界を作る
3. 天井の追加:必要に応じて
4. ライティング:Directional Lightで全体照明
5. 詳細の追加:Static Meshでディテールアップ

Static Meshes and Actors

Placing Static Meshes

1. コンテンツブラウザでStatic Meshを選択
2. レベルにドラッグ&ドロップ
3. Transform ツールで配置調整
4. 詳細パネルでマテリアル設定

Collision settings

// C++でのコリジョン設定例
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
MeshComponent->SetCollisionObjectType(ECollisionChannel::ECC_WorldStatic);
MeshComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);

Lighting basics

Types of light sources

  1. Directional Light: Parallel light rays like sunlight

  2. Point Light: Point light sources like a light bulb

  3. Spot Light: Spot lighting like a flashlight

  4. Sky Light: Reproduction of ambient light

Lighting setting examples

Directional Light の設定:
- Intensity: 3.0
- Light Color: 薄いイエロー (255, 248, 220)
- Cast Shadows: True
- Rotation: (-45°, 30°, 0°)

Applying materials and textures

Creating materials

1. コンテンツブラウザで右クリック
2. 「Material」を選択
3. 名前:M_MyMaterial
4. マテリアルエディタが開く

Basic material settings

Material Graph:
- Texture Sample → Base Color
- Constant (0.5) → Metallic  
- Constant (0.8) → Roughness
- Normal Map → Normal

7. Materials and Textures

Basics of the Material Editor

PBR (Physically Based Rendering)

Unreal Engine uses physically based rendering.

Key parameters:

  • Base Color: Base color

  • Metallic: Metallic (0-1)

  • Roughness: Surface roughness (0-1)

  • Normal: Normal map

  • Emissive: Emissive color

Practical examples of material creation

木材マテリアル:
1. Texture Sample ノード追加
2. Wood_Albedo テクスチャを設定
3. Base Color に接続

4. Constant ノード追加(値:0.0)
5. Metallic に接続

6. Constant ノード追加(値:0.8)  
7. Roughness に接続

8. Texture Sample ノード追加
9. Wood_Normal テクスチャを設定
10. Normal に接続

Texture optimization

Guidelines for texture resolution

- キャラクター:2048x2048 or 4096x4096
- 環境オブジェクト:1024x1024 or 2048x2048
- UI要素:512x512 or 1024x1024
- タイリング テクスチャ:512x512

Compression settings

// テクスチャインポート設定
Compression Settings: TC_Default(通常)
Texture Group: TEXTUREGROUP_World(環境用)
Generate Mip Maps: True
Power of Two Mode: PadToPowerOfTwo

Dynamic materials

Dynamic material manipulation in Blueprint

Event BeginPlay
  └─ Create Dynamic Material Instance
      ├─ Source Material: M_MyMaterial
      └─ Store in Variable: DynamicMaterial

Custom Event: ChangeColor
  └─ Set Vector Parameter Value
      ├─ Target: DynamicMaterial
      ├─ Parameter Name: "BaseColor"  
      └─ Value: New Color

Dynamic material manipulation in C++

// ヘッダーファイル
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
UMaterialInstanceDynamic* DynamicMaterial;

// CPPファイル
void AMyActor::BeginPlay()
{
    Super::BeginPlay();
  
    // 動的マテリアルインスタンスの作成
    if (MeshComponent && MeshComponent->GetMaterial(0))
    {
        DynamicMaterial = UMaterialInstanceDynamic::Create(
            MeshComponent->GetMaterial(0), this);
        MeshComponent->SetMaterial(0, DynamicMaterial);
    }
}

void AMyActor::ChangeColor(FLinearColor NewColor)
{
    if (DynamicMaterial)
    {
        DynamicMaterial->SetVectorParameterValue("BaseColor", NewColor);
    }
}

Material functions and master materials

Creating material functions

1. コンテンツブラウザで「Material Function」を作成
2. 名前:MF_Noise
3. 入力:UV (Vector2)
4. 出力:Result (Scalar)
5. ノイズ生成ロジックを作成

Utilizing Master Materials

マスター マテリアル設計例:
- パラメータ:BaseColor, Metallic, Roughness
- Switch Parameter:UseNormalMap
- テクスチャ スロット:Albedo, Normal, RMA
- バリエーション:Material Instance で調整

8. Animation System

Animation Blueprint

Creating an Animation Blueprint

1. コンテンツブラウザで右クリック
2. 「Animation」→「Animation Blueprint」
3. Skeleton を選択(SK_Mannequin等)
4. 名前:ABP_Character

Basic Structure of State Machines

State Machine Example:
- Idle State
- Walk State  
- Run State
- Jump State

Transitions:
- Idle → Walk: Speed > 0.1
- Walk → Idle: Speed <= 0.1  
- Walk → Run: Speed > 300
- Any → Jump: Is Falling = True

Animation Sequences

Animation Import

1. FBXファイルをコンテンツブラウザにドラッグ
2. Import Options:
   - Skeleton: 既存のSkeletonを選択
   - Animation: Import Animations をチェック
   - Material: Import Materials をチェック

Creating Blend Spaces

1. コンテンツブラウザで「Animation」→「Blend Space 1D」
2. Horizontal Axis: Speed (0-600)
3. Sample Points:
   - 0: Idle Animation
   - 150: Walk Animation  
   - 600: Run Animation

Character Animation Implementation

Animation Integration with C++

// Character クラス
UCLASS()
class AMyCharacter : public ACharacter
{
    GENERATED_BODY()

public:
    AMyCharacter();

    UPROPERTY(BlueprintReadOnly, Category = "Animation")
    float Speed;

    UPROPERTY(BlueprintReadOnly, Category = "Animation") 
    bool bIsInAir;

    UPROPERTY(BlueprintReadOnly, Category = "Animation")
    bool bIsAccelerating;

protected:
    virtual void Tick(float DeltaTime) override;
    void UpdateAnimationProperties();
};

void AMyCharacter::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    UpdateAnimationProperties();
}

void AMyCharacter::UpdateAnimationProperties()
{
    FVector Velocity = GetVelocity();
    Velocity.Z = 0.0f;
    Speed = Velocity.Size();

    bIsInAir = GetMovementComponent()->IsFalling();

    FVector Acceleration = GetCharacterMovement()->GetCurrentAcceleration();
    bIsAccelerating = Acceleration.Size() > 0.0f;
}

Animation Blueprint EventGraph

Event Blueprint Update Animation
  └─ Try Get Pawn Owner
      └─ Cast to MyCharacter
          ├─ Get Speed → Set Speed
          ├─ Get Is In Air → Set Is In Air
          └─ Get Is Accelerating → Set Is Accelerating

IK System

Foot IK Implementation

// Animation Blueprint C++ Class
UCLASS()
class UMyAnimInstance : public UAnimInstance
{
    GENERATED_BODY()

public:
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    float LeftFootEffectorLocation;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    float RightFootEffectorLocation;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    FRotator LeftFootRotation;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    FRotator RightFootRotation;

private:
    void UpdateFootIK();
    float GetIKOffsetForFoot(FName SocketName);
};

9. UI/UX Design

UMG (Unreal Motion Graphics) Basics

Creating Widget Blueprints

1. コンテンツブラウザで右クリック
2. 「User Interface」→「Widget Blueprint」
3. 名前:WBP_MainMenu
4. Widget Designer が開く

Basic UI Layout

Hierarchy Example:
Canvas Panel
├─ Vertical Box (MainContainer)
│   ├─ Text Block (Title)
│   ├─ Spacer
│   ├─ Button (StartButton)
│   ├─ Button (SettingsButton)  
│   └─ Button (ExitButton)
└─ Image (Background)

Responsive Design

Anchor System

UI Element Settings:
- Position: アンカーからの相対位置
- Anchors: 画面上の基準点 (0-1範囲)
- Size to Content: コンテンツに合わせてサイズ調整
- Auto Size: 自動サイズ調整

Screen Resolution Support

Common Anchor Presets:
- Top Left: (0,0) - (0,0)
- Top Center: (0.5,0) - (0.5,0)  
- Top Right: (1,0) - (1,0)
- Center: (0.5,0.5) - (0.5,0.5)
- Fill: (0,0) - (1,1)

Interactive UI

Button Event Handling

// Widget C++ Class
UCLASS()
class UMainMenuWidget : public UUserWidget
{
    GENERATED_BODY()

protected:
    virtual void NativeConstruct() override;

    UPROPERTY(meta = (BindWidget))
    class UButton* StartButton;

    UPROPERTY(meta = (BindWidget))
    class UButton* SettingsButton;

    UPROPERTY(meta = (BindWidget))
    class UButton* ExitButton;

    UFUNCTION()
    void OnStartButtonClicked();

    UFUNCTION()
    void OnSettingsButtonClicked();

    UFUNCTION()
    void OnExitButtonClicked();
};

void UMainMenuWidget::NativeConstruct()
{
    Super::NativeConstruct();

    if (StartButton)
    {
        StartButton->OnClicked.AddDynamic(this, &UMainMenuWidget::OnStartButtonClicked);
    }

    if (SettingsButton)
    {
        SettingsButton->OnClicked.AddDynamic(this, &UMainMenuWidget::OnSettingsButtonClicked);
    }

    if (ExitButton)
    {
        ExitButton->OnClicked.AddDynamic(this, &UMainMenuWidget::OnExitButtonClicked);
    }
}

Data Binding

Property Binding

Health Bar Example:
Progress Bar
├─ Percent: Get Health Percentage (Function Binding)
├─ Fill Color and Opacity: 
│   └─ Bind to Function → GetHealthColor()
└─ Is Enabled: Get Is Alive

Data Binding in Blueprints

Function: GetHealthColor
  ├─ Get Player Character
  ├─ Get Health Percentage
  └─ Lerp (Vector)
      ├─ A: Red Color (1,0,0,1)
      ├─ B: Green Color (0,1,0,1)  
      └─ Alpha: Health Percentage

Animation

Widget Animation

Animation Track Example:
Timeline: 0.0 - 1.0 seconds

Fade In Animation:
- Render Opacity: 0.0 → 1.0
- Translation: (0, 50) → (0, 0)
- Scale: (0.8, 0.8) → (1.0, 1.0)

Widget Animation in C++

UCLASS()
class UMyWidget : public UUserWidget
{
    GENERATED_BODY()

protected:
    UPROPERTY(Transient, meta = (BindWidgetAnim))
    UWidgetAnimation* FadeInAnimation;

    UPROPERTY(Transient, meta = (BindWidgetAnim))
    UWidgetAnimation* SlideOutAnimation;

public:
    UFUNCTION(BlueprintCallable)
    void ShowWidget();

    UFUNCTION(BlueprintCallable)
    void HideWidget();
};

void UMyWidget::ShowWidget()
{
    SetVisibility(ESlateVisibility::Visible);
    if (FadeInAnimation)
    {
        PlayAnimation(FadeInAnimation);
    }
}

10. Performance Optimization

Profiling Tools

Stat Commands

// コンソールコマンド例
stat fps          // フレームレート表示
stat unit         // CPU/GPU使用率
stat memory       // メモリ使用量
stat rhi          // レンダリング統計
stat scenerendering // レンダリング詳細

Unreal Insights

1. エディタで「Tools」→「Session Browser」
2. 「Start Recording」でプロファイリング開始
3. ゲームプレイ後「Stop Recording」
4. データ解析でボトルネック特定

Rendering Optimization

LOD (Level of Detail) Settings

// Static Mesh LOD設定
LOD 0: 100% detail (0-50m)
LOD 1: 75% detail (50-100m)  
LOD 2: 50% detail (100-200m)
LOD 3: 25% detail (200m+)

// 自動LOD生成設定
Reduction Settings:
- Percent Triangles: 0.75, 0.5, 0.25
- Max Deviation: 1.0, 2.0, 4.0

Culling Optimization

// Frustum Culling
r.ViewDistanceScale = 0.8  // 描画距離を80%に

// Occlusion Culling  
r.HZBOcclusion = 1        // HZB Occlusion 有効

// Distance Culling
Static Mesh設定:
- Max Draw Distance: 5000
- Min Draw Distance: 100

Memory Optimization

Texture Streaming

// テクスチャ設定
Texture Streaming:
- Never Stream: False
- Mip Gen Settings: FromTextureGroup
- Texture Group: TEXTUREGROUP_World

// ストリーミングプール設定
r.Streaming.PoolSize = 2000  // 2GB
r.Streaming.MaxEffectiveScreenSize = 1.0

Garbage Collection Optimization

// C++でのメモリ管理
UCLASS()
class AMyActor : public AActor
{
    // UPROPERTY でGC対象に
    UPROPERTY()
    TArray<UObject*> ManagedObjects;

public:
    // 手動でGCをトリガー(注意して使用)
    UFUNCTION(BlueprintCallable)
    void ForceGarbageCollection()
    {
        GetWorld()->ForceGarbageCollection(true);
    }
};

// オブジェクトプール実装例
class ObjectPool
{
private:
    TArray<APooledActor*> AvailableObjects;
    TArray<APooledActor*> UsedObjects;

public:
    APooledActor* GetPooledObject()
    {
        if (AvailableObjects.Num() > 0)
        {
            APooledActor* Object = AvailableObjects.Pop();
            UsedObjects.Add(Object);
            return Object;
        }
        return CreateNewObject();
    }

    void ReturnToPool(APooledActor* Object)
    {
        UsedObjects.Remove(Object);
        AvailableObjects.Add(Object);
        Object->Reset();
    }
};

Gameplay Optimization

Blueprint Optimization

最適化のベストプラクティス:

1. Event Tick の使用を最小限に
   → Timer を使用して更新頻度を制御

2. Cast の最小化
   → Interface の使用を検討

3. 配列操作の最適化
   → For Each Loop より For Loop with Break を使用

4. 文字列操作の最小化
   → Name や Text 使用時は注意

5. 複雑な計算は関数化
   → Pure Function としてキャッシュ活用

Tick Optimization

// C++での Tick 最適化例
AMyActor::AMyActor()
{
    // 必要ない場合は Tick を無効化
    PrimaryActorTick.bCanEverTick = false;
  
    // Tick 間隔の調整
    PrimaryActorTick.TickInterval = 0.1f; // 10fps
}

// 条件付き Tick
void AMyActor::BeginPlay()
{
    Super::BeginPlay();
  
    // プレイヤーとの距離に応じて Tick 制御
    GetWorldTimerManager().SetTimer(
        DistanceCheckTimer,
        this,
        &AMyActor::CheckDistanceToPlayer,
        1.0f, // 1秒間隔
        true  // ループ
    );
}

void AMyActor::CheckDistanceToPlayer()
{
    APawn* Player = GetWorld()->GetFirstPlayerPawn();
    if (Player)
    {
        float Distance = FVector::Dist(GetActorLocation(), Player->GetActorLocation());
      
        // 距離に応じてTick頻度を調整
        if (Distance < 1000.0f)
        {
            SetActorTickEnabled(true);
            PrimaryActorTick.TickInterval = 0.016f; // 60fps
        }
        else if (Distance < 2000.0f)
        {
            SetActorTickEnabled(true);
            PrimaryActorTick.TickInterval = 0.1f;   // 10fps
        }
        else
        {
            SetActorTickEnabled(false);
        }
    }
}

11. Project Completion and Publishing

Build Settings

Development vs Shipping Build

Development Build:
- デバッグ情報付き
- コンソールコマンド有効
- プロファイリング可能
- ファイルサイズ大

Shipping Build:
- デバッグ情報なし  
- コンソールコマンド無効
- 最適化済み
- ファイルサイズ小

Platform-Specific Settings

Windows:
- Target Platform: Win64
- Configuration: Shipping
- Archive Directory: 指定

Android:
- Android SDK/NDK設定
- Package Name: com.yourcompany.gamename
- Minimum SDK Version: 21
- Target SDK Version: 30

iOS:
- Development Team設定
- Bundle Identifier設定  
- Provisioning Profile設定

Packaging

Verifying Project Settings

Project Settings チェックリスト:
✓ Game Name, Description, Version
✓ Icon設定(各解像度)
✓ Splash Screen設定
✓ Input Settings(キー配置)
✓ Rendering Settings(品質設定)
✓ Platform specific settings

Content Optimization

// 未使用アセットの削除
1. Edit → Project Settings
2. Packaging → Packaging
3. "Use Pak File" をチェック
4. "Create compressed cooked packages" をチェック

// アセット参照チェック
Reference Viewer:
1. アセットを右クリック
2. "Reference Viewer" を選択
3. 依存関係を確認
4. 未使用アセットを特定

Debugging and Testing

Automated Testing

// Automation Test例
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
    FMyGameTest,
    "MyGame.Functional.PlayerMovement",
    EAutomationTestFlags::ApplicationContextMask |
    EAutomationTestFlags::ProductFilter
)

bool FMyGameTest::RunTest(const FString& Parameters)
{
    // テストワールドの作成
    UWorld* TestWorld = UWorld::CreateWorld(
        EWorldType::Game, 
        false
    );

    // プレイヤーキャラクターのスポーン
    AMyCharacter* TestCharacter = TestWorld->SpawnActor<AMyCharacter>();
  
    // 移動テスト
    FVector InitialLocation = TestCharacter->GetActorLocation();
    TestCharacter->AddMovementInput(FVector::ForwardVector, 1.0f);
  
    // 1秒待機
    ADD_LATENT_AUTOMATION_COMMAND(
        FWaitLatentCommand(1.0f)
    );
  
    // 結果検証
    FVector FinalLocation = TestCharacter->GetActorLocation();
    TestTrue(
        "Character should move forward",
        FinalLocation.X > InitialLocation.X
    );

    return true;
}

Performance Testing

// Blueprint Performance Test
Custom Event: PerformanceTest
├─ Start Time: Get Game Time in Seconds
├─ Heavy Calculation Loop (1000 iterations)
├─ End Time: Get Game Time in Seconds  
└─ Print String: "Execution Time: " + (End - Start)

Distribution and Marketing

Steam Distribution

Steam Partner準備:
1. Steamworks アカウント作成
2. App ID取得
3. Store Page作成
4. Achievement/Trading Card設定
5. ビルドアップロード(Steamworks SDK)

Mobile Store Distribution

Google Play:
1. Google Play Console アカウント
2. APK/AABアップロード
3. Store Listing作成
4. Content Rating設定
5. Release Management設定

App Store:
1. Apple Developer Program参加
2. App Store Connect設定
3. IPA作成・アップロード  
4. App Review対応
5. Release準備

Continuous Development

Version Control (Git)

# .gitignore 設定例
Binaries/
DerivedDataCache/
Intermediate/
Saved/
*.tmp
*.log

# LFS設定(大容量ファイル用)
git lfs track "*.uasset"
git lfs track "*.umap"  
git lfs track "*.jpg"
git lfs track "*.png"

Updates and Patches

// バージョン管理システム
UCLASS()
class UVersionManager : public UObject
{
    GENERATED_BODY()

public:
    UPROPERTY(BlueprintReadOnly)
    FString CurrentVersion = "1.0.0";

    UPROPERTY(BlueprintReadOnly)
    int32 BuildNumber = 1;

    UFUNCTION(BlueprintPure)
    static FString GetGameVersion()
    {
        return FString::Printf(
            TEXT("%s (Build %d)"),
            *CurrentVersion,
            BuildNumber
        );
    }

    UFUNCTION(BlueprintCallable)
    bool CheckForUpdates();
};

Summary

In this textbook, we have systematically explained practical content from the basics to the application of game development in Unreal Engine.

Key Learning Points

  1. Step-by-step learning: Proceed in the order of basics to application

  2. Practice-oriented: Don't just study theory, actually build projects

  3. Utilize the community: Make use of official documentation and forums

  4. Continuous improvement: Make profiling and testing a habit

Future learning

  • Advanced Topics: Multiplayer, VR/AR, AI

  • Specialization: Paths for programmers, artists, and designers

  • Portfolio: Creating and publishing a collection of your work

  • Industry participation: Getting a job or changing careers in the game industry

Unreal Engine is a very deep tool. Using this textbook as a base, please go ahead and create your own game. Through continuous learning and practice, you will definitely improve your skills.


Reference links:

Happy Game Development! 🎮

いいなと思ったら応援しよう!