Articles
- Listaelem #1
- Listaelem #2
- Listaelem #3
Lejátszó lista
Structure Breakdown
1. Game Mode and Game State
This is your rulebook. Game Mode defines the core gameplay rules, player controls, etc., while Game State keeps track of global game variables like scores or win conditions.
2. Characters and Controllers
In a third-person exploration game, you’ll have a Player Character
usually equipped with a Player Controller
. The character is the avatar, whereas the controller is the “brain,” handling input and decisions.
3. Level Design
You’d create your world with 3D models, landscapes, and architectural elements. This is where you set up your forests to explore or dungeons to crawl.
4. Blueprints
You’d use Blueprints to script the interactions within the game. Think of them as your puppet strings for every object in the game world.
5. UI (User Interface)
HUD, menus, score displays, and the like would be designed and scripted in the UMG (Unreal Motion Graphics) editor.
6. AI (Artificial Intelligence)
If your exploration game has NPCs (Non-Player Characters), you’d set up AI to control them.
7. Interactions
If you can pick up objects, chat with NPCs, or battle foes, these are usually done with specific interaction Blueprints or C++ classes.
8. Animation and Sound
Last but not least, you’d sprinkle in animations and sound effects to bring it all to life.
Engine Workflow
Initialization: When you start the game, Unreal Engine initializes the game world, bringing in the Game Mode, GameState, and other essentials.
Tick Loop: During gameplay, Unreal Engine constantly runs a ‘tick loop,’ where it updates all elements, like physics, graphics, AI, etc., usually 60 times per second (FPS).
Player Input: The Player Controller takes input from the user (like keystrokes or mouse movements) and translates them into actions for the Player Character.
Events & Interactions: As you explore, events are triggered based on your interactions, scripted in Blueprints or C++.
Rendering: All elements in the world are rendered in real-time, creating the visual output you see on your screen.
Shutdown: When the game is over, or you exit, Unreal Engine performs a cleanup, removing all temporary and dynamic elements.
Core Elements of Gameplay Framework:
1. Game Mode
This is like the game’s rulebook. It dictates how players join the game, respawn, and what happens when the game is won or lost. Typically, each level or map will specify which Game Mode to use.
2. Game State
While the Game Mode defines the rules, the GameState keeps track of them. It contains information that should be available to all clients connected to a game, like the score or time remaining.
3. Player Controller
Think of this as the player’s spirit, handling input and possessing characters. One Player Controller usually connects to one human player, but it can also be an AI.
4. Pawn
These are your physical entities, the avatars. Pawns are anything that can be controlled by a Player Controller or AI, like a human, a car, or even a spaceship.
5. Character
A specialized type of Pawn that’s geared towards bipedal movement. This is what you’d typically use for a third-person exploration game.
6. Player State
Contains all the information that is unique to each player, like username, score, and health.
7. HUD (Heads-Up Display)
This is where you’d display game-related information on the screen—ammo, health, etc.
8. World
An environment where all gameplay happens. It’s a collection of levels, essentially your sandbox.
9. Actor
This is the base class for all objects in the Unreal Engine world, from simple lamps to complex NPCs. Every item placed in the game world is an Actor.
How They Interact:
Initialization: Game Mode and GameState are among the first things initialized when a level is loaded.
Gameplay: During gameplay, the Player Controller takes input and translates it into actions performed by the Pawn or Character.
State Management: GameState and PlayerState are regularly updated to keep track of variables like score and time.
Rendering and Interaction: Actors (your NPCs, items, doors, etc.) are placed in the World, and their behavior is governed by the rules defined in the Game Mode and Player Controller.
Event-Driven: When a player does something (like colliding with an object), an event is triggered, which might alter something in the GameState, or cause some other Actor to do something.
Data Storage: Often, you’d need to save and load game states, high scores, etc. The Gameplay Framework allows for that as well, though it’s a bit more advanced.
Core Classes
- Object: The root of all classes, used for basic functionality like garbage collection.
- Actor: Root class for an object that can be placed or spawned in the world.
- Component: Attached to actors, these add functionality and behavior.
Gameplay Classes
- Pawn: A subclass of Actor that can be “possessed” and receive input from a Player Controller.
- Character: A specialized Pawn with built-in functionality for bipedal movement.
- GameMode: Contains game rules, spawn logic, etc.
- GameState: Tracks and replicates game variables like time, score.
- PlayerState: Information specific to individual players, such as health or score.
- PlayerController: Manages input and possesses Pawns or Characters.
UI Classes
- Widget: The base class for all UI elements in Unreal Engine.
- UserWidget: Custom user-created widgets derive from this class.
- HUD: Handles rendering basic UI elements on the screen.
Utility Classes
- GameInstance: Data that persists across levels, like player settings.
- LevelStreaming: Manages dynamically loaded levels for large world support.
- AIController: Specialized Player Controller for handling AI.
Other Specialized Classes
- SkeletalMeshActor: For animated characters and objects.
- StaticMeshActor: For static geometry like buildings.
- Light: Base class for different types of light sources.
- CameraActor: For handling different camera viewpoints.
- TriggerBox/Capsule/Sphere: For creating areas that trigger events.
- Projectile: For creating bullets, arrows, and other fast-moving objects.
Networking Classes
- NetDriver: Manages network communication.
- NetConnection: Represents a network link between server and client.
- Replication: Handles how variables and actions are shared across a network.
This is a high-level overview, so don’t consider it an exhaustive list. As you delve deeper into Unreal Engine, you’ll likely come across many more specialized classes that serve very particular purposes.
What are Blueprints?
Blueprints are visual scripting systems, a way to create game logic without writing code. They offer a node-based interface where you can drag and drop elements to build complex game functions. Each node represents a chunk of functionality, like spawning an actor, running a loop, or calculating math.
Types of Blueprints
- Blueprint Class: Essentially a user-defined class, which you can instantiate into Blueprint objects (actors).
- Level Blueprint: Specific to each level or scene, used for scripting level-specific events like opening doors or triggering cutscenes.
- Animation Blueprint: Used to control complex animation logic for characters or objects.
- UMG Blueprints: These are related to the UI, used in the Unreal Motion Graphics UI Designer.
- Blueprint Interfaces: Sets of functions that can be implemented across various Blueprints, allowing for easier communication between them.
Core Components
- Event Graph: This is where you script what happens in response to different types of game events, like collisions or keypresses.
- Function Graph: A way to package reusable pieces of logic into functions, which you can call from the Event Graph or other places.
- Construction Script: This runs whenever an object is created or modified in the editor, useful for procedural generation.
How Do Blueprints Work with Classes?
Blueprints can extend C++ classes or other Blueprint classes. When you create a new Blueprint, you’re effectively creating a new class, inheriting properties and methods from its parent class. You can override methods or add new functionality with visual scripts.
Common Blueprint Nodes
- Flow Control: These are your loops and branches (like
for
loops,if
statements in code). - Math: Operations like add, subtract, divide, etc.
- Object: Create, modify, or destroy game objects.
- Input: Handle player inputs like key presses, mouse clicks, etc.
Debugging and Profiling
Unreal Engine provides a rich set of debugging tools for Blueprints, including breakpoints, step-by-step execution, and a real-time watch window for variables.
Explore Further
- Data-Driven Gameplay: Learn how to set up data tables and variables for more dynamic gameplay.
- Event Dispatchers and Delegates: Advanced concepts for more complex interactions between Blueprints.
When you create a child Blueprint based on a parent, you inherit all the properties, functions, and variables of that parent. Here’s a rundown of some major parent Blueprint classes and what you inherit:
Major Parent Blueprint Classes
Actor: The base class for objects that can be placed or spawned in the world. Inheriting from this allows you to create any object that will have a presence in your game level.
- Inheritable Features: Transform information, collision settings, built-in events like
BeginPlay
andTick
.
- Inheritable Features: Transform information, collision settings, built-in events like
Pawn: A subclass of Actor that can be controlled by a player or AI.
- Inheritable Features: Movement logic, input handling, basic AI capabilities.
Character: A more specialized Pawn class geared towards humanoid movement.
- Inheritable Features: Pre-built walking, running, jumping logic, skeletal mesh setup for humanoids.
- Inheritable Features: Pre-built walking, running, jumping logic, skeletal mesh setup for humanoids.
GameMode: Defines the rules of the game, how to keep score, what happens when a player dies, etc.
- Inheritable Features: Game rules, spawning logic, game state management.
- Inheritable Features: Game rules, spawning logic, game state management.
GameState: Used to keep track of game-wide properties, which is synced across all connected players.
- Inheritable Features: Score, time, player data.
- Inheritable Features: Score, time, player data.
PlayerState: Maintains information that is unique to each player.
- Inheritable Features: Player score, player name, other custom player-specific variables.
- Inheritable Features: Player score, player name, other custom player-specific variables.
PlayerController: Represents the control setup for a human player, including input handling.
- Inheritable Features: Input schemes, camera controls, UI elements like HUD.
- Inheritable Features: Input schemes, camera controls, UI elements like HUD.
AIController: Special controller for AI characters.
- Inheritable Features: Basic AI logic, pathfinding, decision-making.
- Inheritable Features: Basic AI logic, pathfinding, decision-making.
HUD: For drawing simple 2D elements on the screen.
- Inheritable Features: Screen display logic, 2D rendering methods.
- Inheritable Features: Screen display logic, 2D rendering methods.
UserWidget: Base class for UMG UI elements.
- Inheritable Features: UI elements like buttons, sliders, text fields, and layout logic.
- Inheritable Features: UI elements like buttons, sliders, text fields, and layout logic.
Interface: Though not a class per se, you can create Blueprint Interfaces to define functions that multiple Blueprint classes will implement.
- Inheritable Features: Function signatures for inter-Blueprint communication.
- Inheritable Features: Function signatures for inter-Blueprint communication.
Note on Inheritance
- Override: You can override parent functions to give them custom behavior in the child class.
- Extend: You can add new components, variables, and functionality to child classes.
- Modify: You can alter the inherited variables and components to better suit your specific child Blueprint.