mirror of
https://github.com/kuhyx/praca_magisterska.git
synced 2026-07-04 15:43:14 +02:00
3.2 KiB
3.2 KiB
Unreal Engine Shoot 'em Up Setup Instructions
Since I cannot directly access the running Unreal Editor, I have generated the C++ source code for the core game logic. Follow these steps to set up the game in your Unreal Engine project.
1. Project Setup
- Ensure you have an Unreal Engine 5 C++ project named
MCPGameProject. - If your project is named differently, you will need to rename the
MCPGAMEPROJECT_APImacro and the includes in the provided C++ files.
2. Source Code
I have placed the C++ source files in games/unreal/Source/MCPGameProject/.
Copy these files (STGPawn.h/cpp, STGEnemy.h/cpp, STGProjectile.h/cpp, STGGameMode.h/cpp) into your project's Source/MCPGameProject/ directory.
3. Compilation
I have already compiled the project for you. However, if you do not see the classes in the Editor:
- Restart the Unreal Editor. This is often required when adding new C++ classes.
- If you still don't see them, try clicking the Compile button (or Live Coding icon) in the bottom right corner of the Editor.
4. Blueprint Setup
Once compiled, open the Editor and create the following Blueprints:
BP_Player (Inherits from ASTGPawn)
- Create a Blueprint class based on
ASTGPawn. - Components:
- Select the
ShipMeshcomponent and assign a Static Mesh (e.g., a spaceship or triangle). - Adjust the
SpringArmlength and rotation to get a good top-down view.
- Select the
- Input:
- Go to Project Settings -> Input.
- Add Axis Mappings:
MoveForward(W=1, S=-1),MoveRight(D=1, A=-1). - Add Action Mappings:
Fire(Space/Mouse Left),Special(Q/Right Mouse).
BP_Bullet (Inherits from ASTGProjectile)
- Create a Blueprint based on
ASTGProjectile. - Visuals: Add a Sphere Static Mesh or Particle System to the
RootComponentor as a child. - Collision: Ensure the Collision Component settings allow overlap with Pawns and Enemies.
BP_Enemy (Inherits from ASTGEnemy)
- Create a Blueprint based on
ASTGEnemy. - Visuals: Assign a mesh to
MeshComp. - Variants: You can create child Blueprints for Enemy A, B, C, D and set the
EnemyTypevariable in the Details panel for each.- Tip: Use the Construction Script to change the Mesh or Material based on
EnemyType.
- Tip: Use the Construction Script to change the Mesh or Material based on
BP_GameMode (Inherits from ASTGGameMode)
- Create a Blueprint based on
ASTGGameMode. - Settings: Set
Default Pawn ClasstoBP_Player. - Spawning: The C++ code handles spawning, but you might need to adjust the
SpawnLocationlogic inSTGGameMode.cppif your map coordinates differ.
5. UI (HUD)
- Create a Widget Blueprint
WBP_HUD. - Add Text blocks for Score, Lives, and Timer.
- Bind these text blocks to functions that cast to
BP_Player(for Score/Lives) andBP_GameMode(for Timer) to get the values. - In
BP_Player'sBeginPlayevent, create theWBP_HUDwidget and add it to the viewport.
6. Level Setup
- Place a
BP_GameModein the level or set it in World Settings. - Add a background (e.g., a large plane with a scrolling material).
- Place a
PlayerStartactor.
7. Testing
Press Play. The game should:
- Spawn enemies progressively.
- Allow you to move and shoot.
- Track score and lives.
- End after 90 seconds.