Unreal Engine for Unity Developers

Learn how to get started with Unreal Engine 5 if you previously used Unity.

This page provides an overview of Unreal Engine (UE) for users who are familiar with Unity. If you have some Unity knowledge and want to learn how to apply what you learned to working in Unreal Engine, the sections below will help you get started.

Unreal Editor

The Unreal Editor is where you work on your Unreal Engine project. The screenshot below shows Unity and Unreal Editor, side by side. Different areas are color-coded to indicate common functionality. Each block is labeled to show the equivalent Unreal Engine terminology.

Unreal Editor's layout is fully customizable. You can drag and drop tabs, dock them into the main window, change the color scheme, and more.

unity-to-unreal-engine-ui-comparison.png

Visual comparison between the main UI elements in Unity and Unreal Engine 5. Click the image for full size.

Editing Assets

In Unity, you used the Inspector tab to edit selected Assets in your Project. In Unreal Editor, the Details panel exposes properties of selected objects. Editing complex Assets happens in separate editor windows, which you can either dock into the main UE window or drag somewhere else on your desktop (for example, to a second monitor).

unreal-engine-tabbed-editors.png

Tabbed editors in the Unreal Editor. The Level Editor is in the background, and the Material Editor is currently active.

For a general introduction to the various Asset editors in Unreal Engine, refer to the Tools and Editors page.

Quick Glossary

The following section contains common Unity terms on the left and their Unreal Engine equivalent (or approximation) on the right. Each term in the Unreal Engine column links to separate pages where you can learn more.

Category

Unity

Unreal Engine

Gameplay Types

Component

Component

GameObject

Actor

Prefab

Blueprint Class

Editor UI

Hierarchy Panel

World Outliner

Inspector

Details Panel

Project Browser

Content Browser

Scene View

Level Viewport

Meshes

Mesh

Static Mesh

Skinned Mesh

Skeletal Mesh

Materials

Shader

Material, Material Editor

Material

Material Instance

Effects

Particle Effect

Effect, Particle, Niagara

Game UI

UI

[UMG (Unreal Motion Graphics)](making-interactive-experiences/umg-user-interface)

Animation

Animation

Skeletal Mesh Animation System

Mecanim

Animation Blueprint

Sequences

Sequencer

2D

Sprite Editor

Paper2D

Programming

C#

C++

Script, Bolt

Blueprint

Physics

Raycast

Line Trace, Shape Trace

Rigidbody

Collision, Physics

Runtime Platforms

iOS Player, Web Player

Platforms

Projects and Files

What are the common files and directories of an Unreal Engine project?

Just like Unity projects, Unreal projects always exist in their own directory and have their own project file with the .uprojectfile extension. You can double-click a .uproject file to load your game into Unreal Editor, or right-click it for additional options.

Project folders have various sub-folders that contain your game's content and source, as well as various configuration files and binaries. The most important are the Content folder, which stores all of your project's Assets, and Config folder, which stores the project's configuration (.ini) files.

Where do I put my Assets?

In Unreal Engine, each project has a Content folder. Similar to a Unity project's Assets folder, this is where your game Assets are stored.

If your Unreal Engine project contains C++ classes, these will be located in your project's Source folder on disk.

To import Assets into your game, drop files into your project's Content directory through the Content Browser.

To learn more about the Asset import process, refer to the Importing Assets Directly page.

What file formats are supported?

Unreal Engine 5 supports some of the most common file types:

Asset Type

Supported Formats

3D

.fbx, .obj

Texture

.png, .jpeg, .bmp ,.tga, .dds, .exr, .psd, .hdr

Sound

.wav

Fonts

.ttf, .otf

Videos

.mov, .mp4, .wmv

In addition, you can use specialized plugins to import other types of content, such as:

Plugin

Supported Content

Datasmith

3D scenes and assets from various CAD applications, such as 3ds Max, SketchUp, Revit, and more

LiDAR Point Cloud Plugin

LiDAR point clouds. Refer to the LiDAR Point Cloud Plugin Overview for a list of supported file types.

USD Importer

.usd (Universal Scene Description)

Alembic File Importer

.abc

How is my Scene stored?

In Unity, you placed GameObjects in a scene and saved that as a Scene asset file. Unreal Engine has a Map file that is similar to a Unity scene. Map files store data about your Level and the objects in it, as well as lighting data and certain level-specific settings.

How do I change my project settings?

From Unreal Editor's main menu, go to Edit > Project Settings.

Like Unity's project settings, these settings:

  • Control information about your project, such as project name and icons.

  • Configure game input bindings.

  • Define how the engine behaves when running your project.

  • and so on.

To learn more about the Project Settings window, refer to the Project Settings page.

Unity also has what is called "Player Settings". In Unreal Engine, these are Platform Settings and can be configured under the Platforms section of the Project Settings window.

Where do my source files go?

In Unity, you placed C# source files in your Assets folder. In Unreal Engine, your source files are placed in different locations depending on the type of Unreal project you create:

  • C++ projects have a Source folder in the Unreal project directory. The Source folder contains various files, including C++ source (.cpp) and header (.h) files, as well as some build scripts (Build.cs, Target.cs).

  • Blueprint projects don't have a Source folder. Blueprints can be placed anywhere within the Unreal project's Content folder.

If you want to add C++ code to a Blueprint project, from the Unreal Editor's main menu, go to Tools > New C++ Class.

Double-click a C++ source file in the Content Browser to open it in Visual Studio (Windows) or Xcode (macOS).

From GameObjects to Actors

Where is my GameObject?

In Unity, a GameObject is a "thing" that can be placed in the world. The Unreal Engine equivalent is an Actor. In the Unreal Editor, you can drag a new empty Actor into the viewport from the Create menu in the Main Toolbar, as shown below:

You could build a game out of empty Actors, but Unreal Engine also includes special types of Actors with built-in features, such as a Pawn (for Actors that can be controlled by a player or by AI), or Character (for controllable player characters that require complex locomotion and interactions). Just like empty Actors, you can drop these special types of Actors into the Viewport, then add or customize their properties and components.

Unreal Engine has a Gameplay Framework that works with these special Actors. You will learn more about the Gameplay Framework later.

Actors in Unreal Engine are a little different from GameObjects in Unity. In Unity, GameObject is C# class which you can't extend directly. In Unreal Engine, Actor is a C++ class which you can extend and customize using inheritance. We will talk more about inheritance further down the page.

Where are my components?

In Unity, you added functionality to a GameObject using components. In Unreal Engine, you add components to Actors. After you drop an empty Actor in your Level, select it, and then click the Add Component button in the Details panel and choose a component to add.

In the video below, we are creating a torch by dropping an empty Actor, then adding a mesh component for the base, followed by a light source and then a particle system to create its flame.

In Unity, a GameObject holds a flat list of components. In Unreal Engine, an Actor contains a Hierarchy of components attached to one-another. You can see this in the example above, where the Light and Particle are attached to the Static Mesh. This has some important implications, which will be covered in the Compound Objects section on this page.

From Unity Prefabs to Unreal Engine Blueprint Classes

In Unity, you built a set of GameObjects with components, then created a prefab from them. You could then place instances of the prefab in your world, or instantiate them at runtime.

Unreal Engine has the same kind of workflow, which is based on Blueprint Classes:

  1. Build an Actor with Components.

  2. Click Blueprint > Add Script in the Actor's Details panel to add a Blueprint to it.

  3. Choose where to save your new Blueprint Class.

  4. Click Create Blueprint.

That's all!

You can access your new Blueprint Classes from the Content Browser. Double-click to edit them directly, or drag them into the open Level to place them in the game world.

Where are Script Component and MonoBehaviour?

In Unity, you had Script Components that you dropped on GameObjects to add C# scripting. You created a class that inherited from MonoBehaviour to define what that component does.

Unreal Engine works the same way: you can create entirely new Component classes, using either Blueprint or C++, and add them to any Actor. Similar to adding Blueprint to an Actor, you can add Components to an Actor in one of two ways:

  • From the Actor's Details panel.

  • From the Edit Actor window.

The steps to add a new Component to an Actor are:

  1. From the Actor's Details panel or the Edit Actor window, click Add Component.

  2. Select a Component to add to the Actor. You can either create a new Component, or select from a list of predefined components, such as lights, audio, particle systems, and so on.

    Adding a Component to an Actor

In Unity, when creating a new MonoBehaviour, you received a skeleton class file with a Start() function and an Update() function.

In Unreal Engine, a new component has similar functions:

  • InitializeComponent(), which has the same role as Unity's Start()` function.

  • TickComponent(), which has the same role as Unity's Update() function.

In Blueprint components, these functions appear as visual nodes.

Scriptable Actor Blueprint Classes

Your new Actor Blueprint Class can have its own Blueprint visual scripting. This way, you can add logic to an entire object, not only an individual component. Combined with inheritance (explained below), this gives you a lot of flexibility when designing your game.

In addition to Blueprint Classes supporting visual scripting, Unreal Engine also supports C++ classes implemented with code. Here is a side-by-side comparison of Unity and Unreal Engine code, followed by an Unreal Engine Blueprint that does the same thing.

Unity C#

    using UnityEngine;
    using System.Collections;

    public class MyComponent : MonoBehaviour
    {
        int Count;

        // Use this for initialization.
        void Start ()
        {
            Count = 0;
        }

        // Update is called once per frame.
        void Update ()
        {

            Count = Count + 1;
            Debug.Log(Count);
        }
    }

Unreal Engine C++

    #pragma once
    #include "GameFramework/Actor.h"
    #include "MyActor.generated.h"

    UCLASS()
    class AMyActor : public AActor
    {
        GENERATED_BODY()
        int Count;

        // Sets default values for this actor's properties.
        AMyActor()
        {
            // Allows Tick() to be called
            PrimaryActorTick.bCanEverTick = true;
        }

        // Called when the game starts or when spawned.
        void BeginPlay()
        {
            Super::BeginPlay();
            Count = 0;
        }

        // Called every frame.
        void Tick(float DeltaSeconds)
        {
            Super::Tick(DeltaSeconds);
            Count = Count + 1;
            GLog->Log(FString::FromInt(Count));
        }
    };

Blueprint

(image_28.png)

Blueprint Classes Can Be Extended

Similar to Unity prefabs, you can also instantiate Blueprint Classes in Unreal Engine.

In Unreal Engine, you can create a new Blueprint Class which extends an existing Blueprint Class and augments it with new properties, components, and visual scripting functionality.

For example, you can create a Blueprint Class named Monster, which implements basic monster functionality such as chasing people. You can then create further Blueprint Classes which extend it, such as Dragon (a type of Monster with an added fire-breathing ability), Grue (a Monster which only comes out at night), and 8 other classes for different kinds of Monsters. All of these subclasses of Monster inherit the basic functionality from Monster, and also have new features and abilities of their own.

In Unity, you would implement this by creating many different GameObject prefabs: one for Dragon, one for Grue, and so on. Now, say you want to add some new functionality to all monsters, such as the ability to speak using your new Speak Component. In Unity, you had to go and update all 10 prefabs to individually copy and paste the new functionality into it.

In Unreal Engine, all you have to do is modify the Monster Blueprint Class to add this new ability to speak. That's all! Dragon, Grue, and all the other 8 subclasses of Monster will automatically inherit the new speaking functionality; you don't need to do anything else.

Everything in this section also applies to C++ Classes, as well as both Actors and Components. These systems are designed to support large-scale development of extensible functionality, and can scale to projects with tens or hundreds of developers.

Using Blueprint Scripting, C++, or Both

Blueprint Visual Scripting is ideal for simple in-game logic and action sequencing. Because it's easy to access and control in-game objects visually, Blueprint is a great system for designers, artists, and visually-oriented programmers. You can create small standalone-games and other interactive experiences using just Blueprint.

C++ programming is for larger-scale tasks, such as building gameplay systems, complex AI, and new engine features. If you already have some C++ experience, refer to the Programming with C++ page to learn more about C++ programming in Unreal Engine.

Most projects use a mix of Blueprint and C++. Many developers prototype game functionality using Blueprint, which makes it easy to prototype and iterate, and later move some or all of it to C++ for performance and engineering rigor.

Blueprint Classes Can Extend C++ Classes

Much of the magic of Unreal Engine game development comes from the interplay between programmers implementing new features in C++, which designers and artists can then test in Blueprints so they can give hands-on feedback. Here's how a team might structure a UE-based shooter game implementing pickups, using a mix of C++ Classes systems programming and Blueprint Classes for behavior and appearance:

Class inheritance in Unreal Engine

Transform Components

In Unity, each GameObject had a Transform Component, which gave the GameObject a position, rotation, and scale in the world.

Similarly, Unreal Engine Actors have a Root Component, which can be any subclass of Scene Component. A Scene Component gives the Actor a location, rotation, and scale in the world, which are also applied to all Components parented to the Scene Component. Many of the Components that you will use are subclassed from Scene Component, because it is really useful to have a position!

Even if you place an empty Actor, Unreal Engine will still create a Default Scene Root for that Actor, which is just a plain Scene Component. If you drop in a new Scene Component, it will replace the Default Scene Root.

Compound Objects

In Unity, you created compound objects by constructing a hierarchy of GameObjects and parenting their transforms together:

Unity GameObject relations

In Unreal Engine, you create compound game objects by nesting Components hierarchically:

Unreal Engine Actor and Component relations

As you can see from the diagram, nested hierarchies can be created by attaching Scene Components to one another, since they have a transform - similar to parenting transforms in Unity. Actor Components (the base class for all Components) can only be attached directly to the Actor itself.

Do I build everything out of Components?

It's your choice! Typically, you would use a combination of custom Component types, along with Actor classes that use those Components. As we mentioned before, Unreal Engine has many special types of Actors that guarantee a certain level of capability and always include certain components. For example, a Character always contains a Character Movement Component.

Here are some Unreal Engine Actors that are commonly used:

  • Pawn - A type of Actor representing a controllable game object, typically the player's avatar. Pawns are moved by Players and AI alike through an owning Controller.

  • Character - A more specialized version of Pawn designed for biped avatars (avatars with a skeletal structure similar to a human's, who walk on two legs).

  • Controller - Possesses and controls a Pawn. By separating the Pawn from the controller, you can write AI Controllers that can manipulate a pawn using the same interface the player would.

  • Player Controller - A more specialized Controller designed for getting player input from a player's Gamepad, Touch, or Mouse/Keyboard, and using that input to drive the Pawn or Character they possess.

So is everything an Actor?

Not everything. Actors are the most common class used for gameplay in Unreal Engine and the only type that can be Spawned into the World. In other words, everything you place in your Level will be an Actor.

The other important type to know about is Object. Object is actually the base class of all Unreal classes, including Actor and many others. This is a much lower-level construct than Actor, but still has features that you would expect from a Unreal class, such as Reflection and Serialization. Object is a very basic class you would use when you need to define a new type that just does not fit the mold of an Actor. For example, Actor Component is the base class for all Components, and derives from Object instead of Actor.

What is the Gameplay Framework in Unreal Engine?

When you started a new Unity project, you had to populate things like GameObjects and components manually. Similarly, in Unreal Engine, you can build your game using Actors and Components. However, Unreal Engine has an additional layer called the Gameplay Framework. If you use certain primitive classes and follow specific conventions, your game will automatically acquire additional features that would otherwise be difficult and time-consuming to implement (for example, full multiplayer support).

To use the Gameplay Framework, you need to learn how to use and customize built-in Actor classes included with Unreal Engine, such as Pawn, Character, and Player Controller. If you want to implement multiplayer, for example, you also need to familiarize yourself with how networking and replication work in Unreal Engine.

Writing Code in Unreal Engine

For C++ Programmers

To use Blueprint scripting, you only need Unreal Engine. All the features you need are built in.

To write code in C++, download Visual Studio on Windows, or install Xcode on macOS. When you first create a new C++ project in Unreal Engine (or add C++ code to an existing project), Unreal Engine will automatically create Visual Studio project files for you.

There are two ways to access Visual Studio from your Unreal Engine project:

  • In the Content Browser, double-click a C++ class to open it in Visual Studio.

  • From the main menu, go to Tools > Open Visual Studio. This option only appears if your project contains at least one C++ class.

One important difference in Unreal Engine: You will sometimes have to manually refresh your Visual Studio project files (for example, after downloading a new version of Unreal Engine, or when manually making changes to source file locations on disk.) You can do this in two ways:

  • From Unreal Engine's main menu, go to Tools > Refresh Visual Studio Project.

  • Right-click the .uproject file in your project's directory and select Generate Visual Studio project files.

Writing Event Functions (Start, Update, etc.)

If you previously worked with MonoBehaviors, you should be familiar with methods such as Start, Update, and OnDestroy. Below is a comparison between a Unity behavior and its equivalent for Unreal Engine Actors and Components.

In Unity, you might have a simple component that looks like this:

    public class MyComponent : MonoBehaviour
    {
        void Start() {}
        void OnDestroy() {}
        void Update() {}
    }

In Unreal Engine, you can write code on the Actor itself rather than only coding new component types. This is actually very common and useful.

Unreal Engine Actors have a similar set of methods to Unity's Start, OnDestroy, and Update functions. These are shown below:

C++

    UCLASS()
    class AMyActor : public AActor
    {
        GENERATED_BODY()

        // Called at start of game.
        void BeginPlay();

        // Called when destroyed.
        void EndPlay(const EEndPlayReason::Type EndPlayReason);

        // Called every frame to update this actor.
        void Tick(float DeltaSeconds);
    };

Blueprint

image_29.png

Components in Unreal Engine contain different functions. Here is a basic example:

C++

    UCLASS()
    class UMyComponent : public UActorComponent
    {
        GENERATED_BODY()

        // Called after the owning Actor was created
        void InitializeComponent();

        // Called when the component or the owning Actor is being destroyed
        void UninitializeComponent();

        // Component version of Tick
        void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction);
    };

Blueprint

image_30.png

Remember, in Unreal Engine, you must call the parent class's version of the method.

For example, in Unity C# this would be called base.Update(), but in Unreal Engine C++ you will use Super::TickComponent():

    void UMyComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
    {
        // Custom tick stuff here
        Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
    }

In C++, some classes use the prefix A, while others use the prefix U. A indicates an Actor subclass, whereas U indicates an Object subclass. Another common prefix is F, which is used for most plain data structures and non-UObject classes.

Creating Gameplay in Unreal Engine

The next section covers some advanced Unreal Engine programming concepts. The explanations below assume that you are familiar with Unity C# and want to learn Unreal Engine C++. That said, for most things, you can also use Blueprint and get the same results, so we added examples in both C++ and Blueprint wherever possible.

Let's talk about some of the most common gameplay programming patterns and how to approach them in Unreal Engine. The examples below cover some common Unity functions and how to implement the same functionality in Unreal Engine.

Instantiating GameObject / Spawning Actor

In Unity, you used the Instantiate function to create new instances of objects. This function took any UnityEngine.Object type (GameObject, MonoBehaviour, etc.), and made a copy of it.

    public GameObject EnemyPrefab;
    public Vector3 SpawnPosition;
    public Quaternion SpawnRotation;

    void Start()
    {
        GameObject NewGO = (GameObject)Instantiate(EnemyPrefab, SpawnPosition, SpawnRotation);
        NewGO.name = "MyNewGameObject";
    }

Unreal Engine has two different functions to instantiate objects:

  • NewObject creates new UObject types.

  • SpawnActor spawns AActor types.

UObjects and NewObject

Subclassing UObject in Unreal Engine is much like subclassing ScriptableObject in Unity. These are useful for gameplay classes that do not need to spawn into the world or have attached components like Actors do.

In Unity, if you created your own subclass of ScriptableObject, you would instantiate it like this:

    MyScriptableObject NewSO = ScriptableObject.CreateInstance<MyScriptableObject>();

In Unreal Engine, if you crate your own UObject derived type, you can instantiate it like this:

    UMyObject* NewObj = NewObject<UMyObject>();

AActors and SpawnActor

Actors are spawned using the SpawnActor method on a World (UWorld in C++) object. Some UObjects provide a GetWorld method for you (as an example, all Actors do). This method is how you get a World object.

In the example below, notice that, instead of passing in another Actor, we pass in the class of the Actor we want to spawn. In our example, the class can be any subclass of AMyEnemy.

What if you want to make a copy of another object, like what using Instantiate in Unity allows you to do?

The NewObject and SpawnActor functions can also be given a template object to work with. Unreal Engine will make a copy of that object instead of creating a new object from scratch. This will copy over all of its UPROPERTYs and components.

    AMyActor* CreateCloneOfMyActor(AMyActor* ExistingActor, FVector SpawnLocation, FRotator SpawnRotation)
    {
        UWorld* World = ExistingActor->GetWorld();
        FActorSpawnParameters SpawnParams;
        SpawnParams.Template = ExistingActor;
        World->SpawnActor<AMyActor>(ExistingActor->GetClass(), SpawnLocation, SpawnRotation, SpawnParams);
    }

You might be wondering what "from scratch" means in this context. Each object class you create has a default template that contains default values for its properties and components. If you do not override these properties and do not provide your own template, Unreal Engine will use these default values to construct your object. To help illustrate this, let's first look at a MonoBehaviour example:

    public class MyComponent : MonoBehaviour
    {
        public int MyIntProp = 42;
        public SphereCollider MyCollisionComp = null;

        void Start()
        {
            // Create the collision component if we don't already have one
            if (MyCollisionComp == null)
            {
                MyCollisionComp = gameObject.AddComponent<SphereCollider>();
                MyCollisionComp.center = Vector3.zero;
                MyCollisionComp.radius = 20.0f;
            }
        }
    }

In the example above, we have an int property that defaults to 42, and a SphereCollider component that defaults to a radius of 20.

We can achieve the same thing in Unreal using the object's constructor:

    UCLASS()
    class AMyActor : public AActor
    {
        GENERATED_BODY()

        UPROPERTY()
        int32 MyIntProp;

        UPROPERTY()
        USphereComponent* MyCollisionComp;

        AMyActor()
        {
            MyIntProp = 42;

            MyCollisionComp = CreateDefaultSubobject<USphereComponent>(FName(TEXT("CollisionComponent"));
            MyCollisionComp->RelativeLocation = FVector::ZeroVector;
            MyCollisionComp->SphereRadius = 20.0f;
        }
    };

We set the default property values for the class in the constructor of AMyActor. Note the use of the CreateDefaultSubobject function; we can use this function to create Components and assign default properties to them. All the sub-objects created with this function act as a default template, so we can modify them in a subclass or Blueprint.

Casting from One Type to Another

In this case, we get a component we know we have, then cast it to a specific type and conditionally do something.

Unity C#

    Collider collider = gameObject.GetComponent<Collider>;
    SphereCollider sphereCollider = collider as SphereCollider;
    if (sphereCollider != null)
    {
            // ...
    }

Unreal Engine C++

    UPrimitiveComponent* Primitive = MyActor->GetComponentByClass(UPrimitiveComponent::StaticClass());
    USphereComponent* SphereCollider = Cast<USphereComponent>(Primitive);
    if (SphereCollider != nullptr)
    {
            // ...
    }

Destroying GameObject / Actor

Unity

    Destroy(MyGameObject);

C++

    MyActor->Destroy();

Blueprint

image_23.png

Destroying GameObject / Actor (with 1-Second Delay)

Unity

    Destroy(MyGameObject, 1);

C++

    MyActor->SetLifeSpan(1);

Blueprint

image_24.png ]

Disabling GameObjects / Actors

Unity

    MyGameObject.SetActive(false);

C++

    // Hides visible components
    MyActor->SetActorHiddenInGame(true);

    // Disables collision components
    MyActor->SetActorEnableCollision(false);

    // Stops the Actor from ticking
    MyActor->SetActorTickEnabled(false);

Blueprint

image_25.png ]

Accessing the GameObject / Actor from a Component

Unity

    GameObject ParentGO =
    MyComponent.gameObject;

C++

     AActor* ParentActor =
     MyComponent->GetOwner();

Blueprint

image_32.png ]

Accessing a Component from the GameObject / Actor

Unity C#

    MyComponent MyComp = gameObject.GetComponent<MyComponent>();

Unreal Engine C++

    UMyComponent* MyComp = MyActor->FindComponentByClass<UMyComponent>();

Blueprint

image_33.png ] Click the image for full size.

Finding GameObjects / Actors

Unity C#

// Find GameObject by name

    GameObject MyGO = GameObject.Find("MyNamedGameObject");

    // Find Objects by type
    MyComponent[] Components = Object.FindObjectsOfType(typeof(MyComponent)) as MyComponent[];
    foreach (MyComponent Component in Components)
    {
            // ...
    }

    // Find GameObjects by tag
    GameObject[] GameObjects = GameObject.FindGameObjectsWithTag("MyTag");
    foreach (GameObject GO in GameObjects)
    {
            // ...
    }

Unreal Engine C++

    // Find Actor by name (also works on UObjects)
    AActor* MyActor = FindObject<AActor>(nullptr, TEXT("MyNamedActor"));

    // Find Actors by type (needs a UWorld object)
    for (TActorIterator<AMyActor> It(GetWorld()); It; ++It)
    {
            AMyActor* MyActor = *It;
            // ...
    }

Blueprint

image alt text

Unreal Engine C++

    // Find UObjects by type
    for (TObjectIterator<UMyObject> It; It; ++it)
    {
        UMyObject* MyObject = *It;
        // ...
    }

    // Find Actors by tag (also works on ActorComponents, use TObjectIterator instead)
    for (TActorIterator<AActor> It(GetWorld()); It; ++It)
    {
        AActor* Actor = *It;
        if (Actor->ActorHasTag(FName(TEXT("Mytag"))))
        {
            // ...
        }
    }

Blueprint

image alt text

Adding tags to GameObjects / Actors

Unity C#

    MyGameObject.tag = "MyTag";

Unreal Engine C++

    // Actors can have multiple tags
    MyActor.Tags.AddUnique(TEXT("MyTag"));

Blueprint

image alt text

Adding tags to MonoBehaviours / ActorComponents

Unity C#

    // This changes the tag on the GameObject it is attached to
    MyComponent.tag = "MyTag";

Unreal Engine C++

    // Components have their own array of tags
    MyComponent.ComponentTags.AddUnique(TEXT("MyTag"));

Comparing tags on GameObjects / Actors and MonoBehaviours / ActorComponents

Unity C#

    if (MyGameObject.CompareTag("MyTag"))
    {
        // ...
    }

    // Checks the tag on the GameObject it is attached to
    if (MyComponent.CompareTag("MyTag"))
    {
        // ...
    }

Unreal Engine C++

    // Checks if an Actor has this tag
    if (MyActor->ActorHasTag(FName(TEXT("MyTag"))))
    {
        // ...
    }

Blueprint

image alt text

Unreal Engine C++

    // Checks if an ActorComponent has this tag
    if (MyComponent->ComponentHasTag(FName(TEXT("MyTag"))))
    {
        // ...
    }

Blueprint

image alt text

Physics: RigidBody vs. Primitive Component

In Unity, to give any GameObject physics characteristics, you first had to give it a RigidBody component.

In Unreal Engine, any Primitive Component (UPrimitiveComponent in C++) can be a physical object. Some common Primitive Components are:

  • Shape Components (Capsule, Sphere, and Box)

  • Static Mesh Components

  • Skeletal Mesh Components

Unlike Unity, which separates the responsibilities of collision and visualizations into separate components, Unreal Engine combines the concepts of "potentially physical" and "potentially visible" into a single Primitive Component. Any Component that would have any geometry in the world, that could either be rendered or interacted with physically, is a subclass of PrimitiveComponent.

Layers vs Channels

Collision Channels are the Unreal Engine equivalent of layers in Unity. To learn more, refer to Collision Filtering.

RayCast vs. RayTrace

Unity C#

    GameObject FindGOCameraIsLookingAt()
    {
        Vector3 Start = Camera.main.transform.position;
        Vector3 Direction = Camera.main.transform.forward;
        float Distance = 100.0f;
        int LayerBitMask = 1 << LayerMask.NameToLayer("Pawn");

        RaycastHit Hit;
        bool bHit = Physics.Raycast(Start, Direction, out Hit, Distance, LayerBitMask);

        if (bHit)
        {
            return Hit.collider.gameObject;
        }

        return null;
    }

Unreal Engine C++

    APawn* AMyPlayerController::FindPawnCameraIsLookingAt()
    {
        // You can use this to customize various properties about the trace
        FCollisionQueryParams Params;
        // Ignore the player's pawn
        Params.AddIgnoredActor(GetPawn());

        // The hit result gets populated by the line trace
        FHitResult Hit;

        // Raycast out from the camera, only collide with pawns (they are on the ECC_Pawn collision channel)
        FVector Start = PlayerCameraManager->GetCameraLocation();
        FVector End = Start + (PlayerCameraManager->GetCameraRotation().Vector() * 1000.0f);
        bool bHit = GetWorld()->LineTraceSingle(Hit, Start, End, ECC_Pawn, Params);

        if (bHit)
        {
            // Hit.Actor contains a weak pointer to the Actor that the trace hit
            return Cast<APawn>(Hit.Actor.Get());
        }

        return nullptr;
    }

Blueprint

Click the image for full size.

Trigger Volumes

Unity C#

    public class MyComponent : MonoBehaviour
    {
        void Start()
        {
            collider.isTrigger = true;
        }
        void OnTriggerEnter(Collider Other)
        {
            // ...
        }
        void OnTriggerExit(Collider Other)
        {
            // ...
        }
    }

Unreal Engine C++

    UCLASS()
    class AMyActor : public AActor
    {
        GENERATED_BODY()

        // My trigger component
        UPROPERTY()
        UPrimitiveComponent* Trigger;

        AMyActor()
        {
            Trigger = CreateDefaultSubobject<USphereComponent>(TEXT("TriggerCollider"));

            // Both colliders need to have this set to true for events to fire
            Trigger.bGenerateOverlapEvents = true;

            // Set the collision mode for the collider
            // This mode will only enable the collider for raycasts, sweeps, and overlaps
            Trigger.SetCollisionEnabled(ECollisionEnabled::QueryOnly);
        }

        virtual void NotifyActorBeginOverlap(AActor* Other) override;

        virtual void NotifyActorEndOverlap(AActor* Other) override;
    };

Unreal Engine Blueprint

image alt text

To learn more about setting up collision responses, refer to the Collision page.

Kinematic Rigidbodies

Unity C#

    public class MyComponent : MonoBehaviour
    {
        void Start()
        {
            rigidbody.isKinematic = true;
            rigidbody.velocity = transform.forward * 10.0f;
        }
    }

In Unreal Engine 4, the collision component and rigidbody component are one. The base class for this is UPrimitiveComponent, which has many subclasses (USphereComponent, UCapsuleComponent, etc.) to suit your needs.

Unreal Engine C++

    UCLASS()
    class AMyActor : public AActor
    {
        GENERATED_BODY()

        UPROPERTY()
        UPrimitiveComponent* PhysicalComp;

        AMyActor()
        {
            PhysicalComp = CreateDefaultSubobject<USphereComponent>(TEXT("CollisionAndPhysics"));
            PhysicalComp->SetSimulatePhysics(false);
            PhysicalComp->SetPhysicsLinearVelocity(GetActorRotation().Vector() * 100.0f);
        }
    };

Input Events

Unity C#

    public class MyPlayerController : MonoBehaviour
    {
        void Update()
        {
            if (Input.GetButtonDown("Fire"))
            {
                // ...
            }
            float Horiz = Input.GetAxis("Horizontal");
            float Vert = Input.GetAxis("Vertical");
            // ...
        }
    }

Unreal Engine C++:

    UCLASS()
    class AMyPlayerController : public APlayerController
    {
        GENERATED_BODY()

        void SetupInputComponent()
        {
            Super::SetupInputComponent();

            InputComponent->BindAction("Fire", IE_Pressed, this, &AMyPlayerController::HandleFireInputEvent);
            InputComponent->BindAxis("Horizontal", this, &AMyPlayerController::HandleHorizontalAxisInputEvent);
            InputComponent->BindAxis("Vertical", this, &AMyPlayerController::HandleVerticalAxisInputEvent);
        }

        void HandleFireInputEvent();
        void HandleHorizontalAxisInputEvent(float Value);
        void HandleVerticalAxisInputEvent(float Value);
    };

Blueprint

image alt text

This is what your input properties in your Project Settings might look like:

Input settings in Unreal Engine

To learn more about how to set up input for your Unreal Engine project, refer to the Input page.

FAQ

How do I load my last project automatically?

You can configure Unreal Engine to load the last project you were working on automatically on startup. When you open a project from the Epic Launcher, enable the Always Lost Last Project on Startup option on the Unreal Engine start screen.

always-load-last-project-at-startup.png

Where do I set input bindings for my game?

In Unity, you used the Input Manager settings for your project to set up default bindings.

In Unreal Engine, you configure input bindings from the Project Settings window, in the Input category. In this window, you can add various buttons (actions) and analog controls (axes). Give each control a name and default binding. Once you do that, you can get callbacks to your game's Pawn when input events are triggered.

To learn more about how to set up input for your Unreal Engine project, refer to the Input page.

How do I change the starting scene of my project?

By default, Unreal Engine loads the default Level of your project when you open it. You can change this behavior in the Project Settings window (main menu: Edit > Project Settings), in the General > Loading & Saving category.

How do I run my game?

There are several ways to play-test (run) your game:

  • Directly in the Unreal Editor, by clicking the Play button on the Main Toolbar.

  • As a standalone process, by clicking the Platforms button on the Main Toolbar, then selecting your machine from the drop-down list. Note that this will first build an executable for your platform; for example, if you are working on a Windows machine, this will build a Windows executable.

  • On a different platform (for example, a mobile device or web browser), by clicking the Platforms button on the Main Toolbar, then selecting the platform you want to run your game on. Note that you will need to install all required dependencies first.

To learn more about running your Unreal Engine game on different platforms, refer to the following pages:

What units are these?

In Unity, the primary unit of measurement is one meter. In Unreal Engine, the primary unit of measurement is one centimeter.

So, if you move something 1 unit (meter) in Unity, that is equivalent to moving something 100 units (centimeters) in Unreal Engine.

If you want to move something 2 feet in Unity, that would be 0.61units (meters). In Unreal Engine, the equivalent is 61 units (centimeters).

Which way is up in Unreal Engine's coordinate system?

Both Unity and Unreal Engine use a left-handed coordinate system, but the axes are named differently. In Unreal Engine, positive X is "forward", positive Y is "right" and positive Z is "up".

How do I see Log Output from my game?

Click the Output Log button in the bottom toolbar.

How do I throw exceptions?

Unlike Unity, Unreal Engine does not use exception handling. Instead, use the check() function to trigger a critical assertion error. You can pass in an error message. If you want to report an error but not halt the program, use ensure() instead. This will log an error with a full call stack, but program execution will continue. If you had a debugger attached, both functions will break into the debugger.

Where is the .NET Framework?

Unlike Unity, Unreal Engine does not use the .NET framework. Unreal Engine has its own set of container classes and libraries. Below is a list of common container comparisons:

.Net Framework

Unreal Engine

String

FString, FText

List

TArray

Dictionary

TMap

HashSet

TSet

You can learn more about other Unreal Engine containers here.

Does Unreal Engine automatically reload code changes?

Yes! You can leave the editor open while you write code. Start a compile from Visual Studio after you have finished editing code, and the editor will "hot reload" your changes automatically.

Finding Help and Answers

Thank you for reading! This guide was initially created for the Unreal community with the help of Unreal Engine developers everywhere, and we have now updated it for Unreal Engine 5. We'll keep improving this document as we learn more about what is most helpful when transitioning to Unreal Engine, so we very much appreciate any feedback and corrections you can offer.

To learn more about Unreal Engine, you can refer to rest of this documentation website, or visit the resources below:

Tags
Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel