Introduction to Unreal Engine

Post on 10-Apr-2023

0 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Introduction to Unreal EngineJaanus Jaggo

Unreal EngineUnreal Engine is a powerful 3D game engine developed by Epic Games.

Unreal Engine 4 released to public in 2014.

Platforms: Windows, macOS, Linux, iOS, Android, Web

● primarily 3D● C++, Blueprints

History of Unreal Engine

1995 - Tim Sweeney (founder)started working on Engine for Unreal

2000 - Unreal Engine 2 2004 - Unreal Engine 3

2009 - Unreal Development Kit (UDK)Free version of UE3 available for general public

2014 Unreal Engine 42015 - no subscription (5% revenue share)

2020 - free until 1M$ revenue (after that 5% revenue share) Soon - Unreal Engine 5

C++ vs Blueprint Scripting

C++Pros:● Extreme performance● Source code access● Can do everything

Cons:● High complexity● Long compilation times● Easy to make mistakes

BlueprintsPros:● Easy to learn● Easy to prototype● Artist friendly● Harder to make crashing mistakes

Cons:● Slower performance● Some patterns are ugly (loops)● Can become messy● Less features

Architecture● Levels / Actors / Components● Blueprints● Game Mode / Game State / Game Instance● Player related classes● Accessing the main classes

Levels / Actors / ComponentsUnreal game is made of Levels, Actors and Components.

● Levels are similar to Scenes in Unity.● Actors are similar to GameObjects in Unity.● Components are similar to MonoBehaviours in Unity.

Every actor has a root component that can have an hierarchy of child components.

Unlike in Unity and Godot, the actors can’t be directly parented under each other but components can. There is a special component “child actor component” in case you need to parent actors under each other.

BlueprintsBlueprints are the script files that allow to define custom Actors and Components (and other things).

When making a blueprint you have to choose its parent class. This can be a C++ file or another blueprint.

These are the common parent classes

These are all the other classes that chosen

BlueprintsMain things that a blueprint has:

1. Component tree2. Event Graph with events3. Functions / Macros4. Variables5. Construction Script6. Class Settings / Class Defaults

Game Mode / Game State / Game InstanceMain configurations are in Edit → Project Settings → Maps & Modes

Game Mode: defines the rules of the game

● The number of players● How players spawn● Is the game paused● Transitions between levels

Game State: a public variable container for game mode

Game Instance: holds all presistent variables (data stored between levels)

Game ModeGame Mode defines the types of other main classes:

These are the most important ones for now

Player related classesPawn - Base class for any self moving actor (can be possessed)

Character - Pawn that can walk around

Player Controller - Responsible for sending player input to the possessed pawn. (Also responsible for the HUD)

Player Controller Character

Pawn

posesses

NB! In the First Person Template the input logic is FirstPersonCharacter class for simplicity. For a more complex game it should go to the PlayerController class.

Referencing main classesReferencing game related classes is simple, there are built in functions for each one of them:

You also need to cast them in case you created your own:

Referring to the player character should go through Player Controller.

In a single player game, the Player Index is always 0.

Blueprints Compendiumhttps://romeroblueprints.blogspot.com/p/table-of-contents.html

● Branch / Sequence / Switch● Loops● Variables● Events● Timers / Delays

Blueprint scriptingBranch Sequence

Switch

Blueprint scriptingForeach loop For loop

Blueprint scriptingVariables

Blueprint scriptingArrays

Blueprint scriptingEvents

Event dispatcher

Blueprint scriptingTimer Delay

Using timer handle:

Other things covered during labs● Enumerators● Data Tables● Interfaces● Functions / Macros● Construction Script● Level Blueprint

NetworkingUnreal engine features a robust networking framework.

All the previously studied components (GameMode, PlayerController, Character...) are made to work with multiplayer.

Unreal documentation suggests that “you should always program for multiplayer unless you are completely certain that your project will never need multiplayer features.”

Unreal Engine uses a client-server model. One computer acts as a server and hosts a sessions while other players’ computers connect as clients.

https://docs.unrealengine.com/en-US/Gameplay/Networking/Overview/index.html

NetworkingThe server, as the host of the game, holds the one true, authoritative game state.

The clients each remote-control Pawns, that they own on the server. They send procedure calls to them to perform in-game actions.

Server replicates information to each client, telling them what Actors should exist, how those Actors should behave, and what values different variables should have.

https://docs.unrealengine.com/en-US/Gameplay/Networking/Overview/index.html

Networking Modes and Server Types● Standalone - The game is running as a server that does not accept

connections from remote clients. It will run both server-side and client-side logic. (single-player and local multiplayer games)

● Client - The game is running as a client that is connected to a server. It will not run any server-side logic.

● Listen Server - The game is running as a server hosting a network multiplayer session. It accepts remote clients and has local players directly on the server. (casual cooperative and competitive multiplayer games)

● Dedicated Server - The game is running as a server hosting a network multiplayer session. It accepts remote connections but has no local player. It discards graphics, sounds, input etc. (secure or large-scale multiplayer games)

ReplicationReplication is the process of reproducing game state information between different machines in a network session.

By default most Actors do not have replication enabled and will perform all their functions locally. You can enable it by setting Replicates = true.

Replication

Replication Feature Description

Creation and Destruction When object is spawned / destroyed on server, it automatically gets spawned / destroyed on all clients.

Movement Replication When Actor has Replicate Movement enabled, it will replicate the Location, Rotation and Velocity.

Variable Replication Any value that is set to replicate will replicate whenever their value is changed.

Component Replication Actor components replicate as part of the Actor that owns them.

Remote Procedure Calls (RPCs) Special functions that are transmitted to specific machines in a network game.

OwnershipPawns in a network game are owned by a Player Controller.

Any time that Pawn calls a client-only funcion, it will be directed only to the owning player’s machine.

Actors that have their Owner set to a specific Pawn belong to that Pawn’s owning client. They will also direct client-only functions to their owner’s machine.

Use Is Locally Controlled to determine whether or not a Pawn is on its owning client.

Variable replicationTo replicate a variable you can either use:

● Replicated● RepNotify

RepNotify also creates a function that triggers locally when the variable is updated.

Remote Procedure Calls (RPC)They can be called from any machine but will direct their implementation to happen on a specific machine.

NB! Using variables and RepNotifies are preferable over using RPC’s whenever possible.

RPC Type Description

Server Called only on the server.

Client Called only on the client that owns the Actor where the function is.

NetMulticast Called on all clients that are connected to the server as well as the server itself.

Network CompendiumOne of the best source of information for developing multiplayer game in UE.

http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf

Main classes in replication

Main classes example

top related