mirror of
https://github.com/kuhyx/praca_magisterska.git
synced 2026-07-04 13:23:05 +02:00
* Initial plan * Add C++ code-first tutorial approach for Unreal game Co-authored-by: kuhyx <147418882+kuhyx@users.noreply.github.com> * Add quick start guide for code-first approach Co-authored-by: kuhyx <147418882+kuhyx@users.noreply.github.com> * Restructure C++ tutorial into part-by-part format and add migration guide Co-authored-by: kuhyx <147418882+kuhyx@users.noreply.github.com> * Address PR feedback: improve part-1, add Expected Results, split parts 4-9 into separate files Co-authored-by: kuhyx <147418882+kuhyx@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kuhyx <147418882+kuhyx@users.noreply.github.com>
1.9 KiB
1.9 KiB
Part 8 (C++): Create Game Mode
← Previous: Part 7 (C++) - Create UI | Back to Index | Next: Part 9 (C++) - Final Setup →
Overview
Create a custom Game Mode to set the default pawn class and manage game rules.
Time: ~5 minutes
Step 8.1: Create STGGameMode C++ Class
- Tools → New C++ Class
- Choose "Game Mode Base" as parent
- Name:
STGGameMode - Create Class
Step 8.2: Define Game Mode
STGGameMode.h:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "STGGameMode.generated.h"
UCLASS()
class BULLETHELLGAME_API ASTGGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
ASTGGameMode();
};
STGGameMode.cpp:
#include "STGGameMode.h"
#include "STGPawn.h"
ASTGGameMode::ASTGGameMode()
{
// Set default pawn class to our player
DefaultPawnClass = ASTGPawn::StaticClass();
// Disable auto-possess (we'll handle spawning ourselves)
bStartPlayersAsSpectators = false;
}
Step 8.3: Set Game Mode in Project Settings
- Edit → Project Settings
- Project → Maps & Modes
- Under "Default Modes":
- Default GameMode → Select
STGGameMode
- Default GameMode → Select
- Close Project Settings
Step 8.4: Test
Create a new level or use existing one:
-
File → New Level → Empty Level
-
Save as
BulletHellLevel -
Add:
- Player Start (from Place Actors panel)
- STGEnemySpawner
- STGGameDirector
- STGHUDManager
- Directional Light (for visibility)
-
Press Play
Expected Result:
- ✅ Player automatically spawns at Player Start location
- ✅ No need to manually drag BP_Player into level
- ✅ All game systems work together
← Previous: Part 7 (C++) - Create UI | Back to Index | Next: Part 9 (C++) - Final Setup →