Unreal Unity



  • Unity vs Unreal is the most searched term when it comes to game engine battles, as they are the industry standards in game development. That doesn’t mean that these two are the only game engines that you can use but these engines have evolved along with game development technology and now are the best available.
  • Unity is much better for 2D games. Unreal support is very limited, it has only Paper 2D plugin. Yes, a single plugin and nothing around in the engine is designed with 2D in mind. Even the orthographic camera doesn't fully work with Unreal's lightning. Meanwhile, Unity provides a lot: 2D lightning, animation tools, sprites, tilemaps.
  • Both Unity and Unreal have vibrant communities and alongside that all the books, tutorials, and other materials that go along with large communities. That said, Unity’s community is much larger with perhaps 3-4x more published books available, as well as a massive number of community driven tutorials.
Reading Time: 7minutes

I believe that each one of us does get bored with our everyday schedule at some point in time and starts looking out for better recreational avenues to unwind. To remove this boredom, many people prefer playing video games. Games are a good source of entertainment and also teach us a lot about planning, strategy making, teamwork, and quick reflexes. You can also say that they teach us how to become a good strategist.

In case you’re new to the conversation, the first thing you should know is that Unity and Unreal Engine are two of the most prominent engines used for software development today. Though both started as tools for game building, they have evolved into much bigger and better platforms. Let’s take a closer look at the changes and current state. Virtual Reality (VR) – Unity excels in VR as the plugins are very versatile and integrate into the overall XR infrastructure. Multiplayer – Both engines can do multiplayer but Unreal is the only one with integrated support for it. Unity requires 3rd party tools support.

Due to the craze of games, many people start leaning towards learning game development. I mean, wouldn’t it be great if people played and enjoyed the game you created? There’s no joy next to that. So people start learning the programming languages and basics.

The main component for developing a game is the Game Engine. It combines all the elements like sound, graphics, artificial intelligence(AI), background, and many other components. The most common gaming engines used are Unity from Unity Technologies and Unreal from Epic Games.

The biggest confusion in game development is whether you should go for Unity or Unreal. So in this article, we are going to do a comparison between Unreal Engine Vs Unity to know more about them.

But before that, let us have a brief description of Game Engine-

Game Engine

A game engine, also known as a game architecture, game framework, or game frame, is a software development environment designed for people to build video games. Developers use game engines to construct games for consoles, mobile devices, and personal computers.

The core functionality typically provided by a game engine includes a rendering engine (“renderer”) for 2D or 3D graphics, a physics engine or collision detection (and collision response), sound, scripting, animation, artificial intelligence, networking, streaming, memory management, threading, localization support, scene graph, and may include video support for cinematics.

Now with the basics done, let us look at Unreal and Unity Engine.

What is Unity?

Unity is a game engine developed by Unity Technologies. It is one of the most widely used engines in the game development industry. Since it is a cross-platform engine, it can be used to create games for different platforms like Windows, iOS, Linux, and Android.

The engine has been adopted by industries outside video gaming, such as film, automotive, architecture, engineering, and construction. As of now, the engine supports as many as 25 platforms. The latest version of the Unity at the moment is Unity 2019.2.

According to Wikipedia, The engine can be used to create three-dimensional, two-dimensional, virtual reality, and augmented reality games, as well as simulations and other experiences.

It has its own Integrated Development Environment(IDE) and is famous for creating interactive games. It contains many elements like Assets, GameObjects, Components, Scenes, and Prefab.

Unity has been used to develop many renowned games like-

  • Kerbal Space Program
  • Praey for the Gods
  • Monument Valley 2
  • Ghost of a tale
  • Firewatch
  • Hearthstone- Heroes of warcraft
  • Wasteland 2
  • Battlestar Galactica Online
  • Rust
  • Temple Run Trilogy
  • Escape plan
  • Pokemon Go
  • Super Mario Run

Advantages of Unity

Advantages of game development using Unity are-

  1. Debugging – Debugging in Unity is a hassle-free work and easy job for any developer. The support for debugging is nice because all the variables are displayed in the gameplay.
  2. Graphics – It supports high-quality audio and visual effects that support easing the game development. The visuals are capable of adapting to every screen and device.
  3. Analytics – Unity consists of built-in analytics which you can easily find in the editor. Thanks to Unity Analytics, you can get very deep insights into your game. It gives you information that can be used to improve the gameplay by doing some modifications and offer an awesome gaming experience for the players.
  4. Community Support – Unity enjoys the support of a large number of users that help in keeping the engine up-to-date and free of bugs.
  5. Platform Support – This is one of the biggest strengths of Unity. Since it offers support to 25 different platforms, it becomes easy to share an app created in one platform among others. Besides, its methodology allows for speedy prototyping, which in turn reduces the time required to develop apps.
  6. IDE – The engine consists of an in-built IDE which is used to write the project code. Additionally, the integrated development editor supports programming languages like JScript or C# for scripting. Along with this, it provides features that are suitable for game development.

Disadvantages of Unity

Disadvantages of Unity are-

  1. Most of the good features of Unity are present in the Pro version, which is very expensive.
  2. Source Code is not open, meaning you can’t use it outside Unity.
  3. It takes more time to render a project.

What Language is used by Unity?

Unity uses C# as the scripting language for both the Unity editor in the form of Plugins and games. Before C#, it used a language known as Boo which was removed with the release of Unity 5. It also uses a Javascript language known as Unity Script. Unity takes your C#/ JS/Boo code and compiles it to run on iOS, Android, PC, Mac, Xbox, PS3, Wii, or web plugin.

Depending on the platform that might end up being Objective C or something else, but that’s completely transparent to you. There’s really no benefit to knowing Objective C; you can’t program in it.

What is Unreal Engine?

Unreal is a game engine developed by Epic Games which was first showcased in 1998 first-person shooter game Unreal. Initially, it was developed as a game engine for the first-person shooter. But over the year, it is being used to develop for other genres like platformers, MMORPGs, and other RPGs. The latest version of Unreal is 4.25.

Some of the famous games developed using the Unreal Engine are-

  • Fortnite
  • Life is Strange
  • Gears of War
  • Deus Ex
  • Unreal Tournament 2004
  • Enslaved: Odyssey to the West
  • Borderlands 2
  • Spec Ops: The Line
  • Gears of War 3
  • XCOM: Enemy Unknown
  • Bioshock
  • Borderlands 2: Tiny Tina’s Assault on Dragon Keep
  • Mass Effect 2
  • Occupy White Walls
  • Batman Arkham City

Advantages of Unreal Engine

  1. Performance – The performance of the Unreal Engine is great due to the fact that it uses very little memory and other resources.
  2. AAA Games – Unreal is widely preferred when it comes to making big-budget games where the quality of the game needs to be over the roof.
  3. Open-Source – Since Unreal Engine is open-source, this makes its development very easy and increases its efficiency.
  4. Iteration – Unity makes rapid iteration easy, which makes it useful when making a new project.
  5. VR – It provides good integration for VR for achieving the best quality picture.

Disadvantages of Unreal

Disadvantages of Unreal are:

  1. It consists of fewer assets because they upload a selected asset after a thorough process.
  2. It is not preferable for small game development because it is used by developers only when they want to create a big project.
  3. Although the engine is free, it does have its own clause. When you publish your game, you would need to pay a royalty of 5%.

What Language is used by Unreal Engine?

For Unreal Engine, the scripting language used is C++. But when you’re building the actual game code, you would require a mixture of Blueprint(Epic’s own proprietary language) and C++. It has great blueprints that work like building blocks so even artists without any programming knowledge can use the engine to assemble and adjust basic things.

Comparison-Unity Vs Unreal Engine

Now that we have discussed Unity and Unreal individually, let us see the comparison between them-

  1. Community – Both engines have a very large base of active users and they are regularly updated. Unity 3D has been accessible long before Unreal 4, so it has a comparatively larger community base. Not only this, but most of the clients also prefer Unity as it is more widely used.
  2. Language – For scripting language, Unity uses C#, and Unreal uses C++. It is widely accepted that C# is more suitable for development than C++, so development is faster in Unity.
  3. Pricing – Unity is available for free but you lose some key aspects there. If you want to use the complete version, you can upgrade to the Unity Pro version which costs around $1500 for a one-time purchase or a monthly subscription for $75. In the case of Unreal, it is also completely free but you would owe some royalties to them after launching it.
  4. Asset Store – Asset Store is basically a location from where you can download mods like textures and props for any game and use it by installing it. In this segment, Unity has a wider range of mods available for its game in comparison to Unreal. Unreal has around 10000 assets while Unity has 31000 assets, almost 3 times!
  5. Documentation – Both of them have good documentation explaining how to use them. But when you go to look for their tutorials, the picture becomes clear. For instance, the number of courses for Unreal on Udemy is around 2200 whereas it is 5500 for Unity. Though most of these are related to game development, basic knowledge can be used for app development.
  6. Graphics – Both of them have good graphics but Unreal is the better one of the two. When developing a big game, Unreal is preferred over Unity because of its graphic quality.
  7. Source Code – Source code is open for Unreal, which makes game development and processing a lot easier. For Unity, the source code is not open. You can obtain it but you would need to pay money for it.
  8. Rendering – Rendering is faster in Unreal which makes the post-processing even faster. In the case of Unity, rendering is slow. Due to this, the processing of the project is slow and it takes some time to develop.

Unreal Engine Vs Unity: Pricing in Detail

The full version of Unreal Engine 4 will be available for free if your game revenue is less than $3,000/quarter; if it is more than that, then 5 percent of your game’s gross revenue will be paid.

The Unity Gaming Engine has a free Personal Plan that is fully free and great enough to be used by individuals and small businesses. Unity provides two types of packages for larger organizations. The Plus package is available to companies with sales of less than $200K in the last 12 months prior to purchase. This bundle is available on a monthly/annual subscription if you choose. The monthly subscription to the Plus bundle is $35 a month and the annual subscription to Unity Plus is $299 on a prepaid basis.

Unity provides a Pro subscription to companies with sales greater than $200K in the last 12 months prior to purchase. The Pro subscription has few extra functionalities, such as source code access and priority customer care and support.

Companies can choose to buy one of the three packages available for Unity Pro subscription. There is a 2-year prepaid package costing $2,850, an annual prepaid package costing $1,500, and a monthly prepaid package valued at $125 a month.

Besides that, there are different costs for iOS or Android game development. So, if you’re planning something massive, then developing with Unity 3D can be a great option. However, if you are working on a basic or experimental scheme, the Unreal Engine can be a saver.

Conclusion

Game engines are an important element in game development. We cannot imagine development without them. In these, we have two most preferred options- Unity and Unreal. Unity is renowned for its cross-development support and for making 2D and 3D simulations. Unreal is preferred for building large games (AAA title) because of its beautiful graphics. Both have their own set of advantages and drawbacks. Some may prefer Unity while some may prefer Unreal. You can check both for yourself and decide which one suits you!

What is a Game Engine?

A game engine is a software development environment designed for people to build video games.

Which is Better: Blender or Unity?

Blender and Unity are not the same thing, Unity is game engine, which means that its purpose is to create games, and you can program in it using C# or Javascript. But you cannot make 3d models in it.

Is Unreal Engine Good for Beginners?

Developing in Unreal Engine 4 is very simple for beginners. Using the Blueprints Visual Scripting system, you can create entire games without writing a single line of code! Combined with an easy-to-use interface, you can quickly get a prototype up and running.

How does Unity Game Engine Work?

Unreal 5 Vs Unity

Unity is a 2D/3D engine and framework that gives you a system for designing game or app scenes for 2D, 2.5D and 3D. Unity allows you to import and assemble assets, write code to interact with your objects, create or import animations for use with an advanced animation system, and much more.

Can you use C++ in Unity?

It is possible to use C++ with the Free version of Unity, although it is easier to work with if you have a Unity Pro license.

How useful was this post?

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Please do Rate Us and Share!

Related Blogs

  • Tableau vs Power BI vs Qlik Sense | Comparison of Top 3 BI Tools

    Reading Time: 7minutes Post Views: 194 Big data is a treasure trove for all types of companies. Every company deserves the best Big Data data analysis and visualization tool. In this post, we will try to provide you with as much detail as possible...

    Hire Top 1% Remote Developers, Free For The First Week

    Connect with quality remote developers and code your ideas away.

    No thanks, I'm not hiring right now.

This guide provides an overview of UE4 from the viewpoint of a Unity user, and aims to help you translate your existing Unity experience into the world of UE4.

The Editor

Below are pictures of the Unity Editor and Unreal Editor, color-coded to indicate common functionality. Each block is labeled to show the equivalent UE4 terminology. Unreal Editor's layout is fully customizable by dragging and dropping tabs around.

Editing Assets

In Unity, the Inspector tab is used to edit selected assets in your Project. In UE4, the Details panel exposes properties of selected objects, while larger editing tasks lead to a dedicated window or tab. New tabbed windows will open for each edited asset, similar to a web browser. Of course, you can freely drag the tabs around or float them as standalone windows.

Quick Glossary

The following section contains common Unity terms on the left and their UE4 equivalents (or rough equivalent) on the right. UE4 keywords link directly to more in-depth information inside Unreal Engine's Online Documentation.

Category

Unity

UE4

Content and Source sub-folders.

Where do I put my assets?

In UE4, each project has a Content folder. Similar to a Unity project's Assets folder, this is where your game assets are stored. To import assets into your game, simply drop files into your project's Content directory and they will be automatically imported and appear in the Content Browser. The assets in the editor will update automatically as you make changes to the files using an external program.

What common file formats are supported?

Unity supports a wide array of file formats. UE4 supports the most common file types:

Asset Type

Supported Formats

All project settings can be found from the main menu under Edit / Project Settings. Like Unity's project settings, these allow you to specify information about your project (such as project name and icons), configure game input bindings, and define how the engine behaves when running your project. You can learn more about individual project settings here. Unity also has what is called 'player settings'. In Unreal, these are 'platform settings', and can be found under the 'Platforms' category in your project settings.

Where do my source files go?

In Unity, you are accustomed to placing C# source files in your assets folder.

UE4 works differently. For projects that have C++ code, you will find a Source sub-folder under the project directory that has various files, including C++ source (.cpp) and header (.h) files, as well as some build scripts (.Build.cs, .Target.cs) However, Blueprint-only projects will not have a Source folder.

Unreal unit scale

The easiest way to get started with C++ in UE4 is to use the editor to Add Code to Project (in the main File menu), or to simply create a new C++ project from scratch from one of the many templates. You can find C++ classes right in the Content Browser and can open the files in Visual Studio or Xcode by Double-clicking on their icons.

From GameObjects to Actors

Where is my GameObject?

In Unity, a GameObject is a 'thing' that can be placed in the world. The UE4 equivalent is an Actor. In the Unreal Editor, you can drag a new Empty Actor into the viewport from the Placement panel:

You could build a game out of Empty Actors, but UE4 also includes special types of Actors with built-in features, such as a Pawn (for players or AI objects), or Character (for animated creatures.) Just like Empty Actors, you can drop these special types of Actors down, then add or customize their properties and components. You will learn more about it later, but for now try to remember that UE4 has a Gameplay Framework that works with these special Actors.

Actors in UE4 are a bit different than GameObjects in Unity. In Unity, GameObject is C# class which you cannot directly extend. In UE4, Actor is a C++ class which you can extend and customize using inheritance. We will talk about this more later on!

Where are my components?

In Unity, you add components to a GameObject to give it functionality.

In UE4, you add components to Actors. After you have dropped an Empty Actor in your level, click the Add Component button (in the Details panel) and choose a component to add. Here, 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 hold a flat list of components, but in UE4 an Actor actually 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 Mesh. This has some important implications discussed later in Complex Actors and GameObjects.

From Unity Prefabs to UE4 Blueprint Classes

Unity's workflow is based on prefabs. In Unity you build a set of GameObjects with components, then create a prefab from them. You can then place instances of the prefab in your world, or instantiate them at runtime.

UE4's corresponding workflow is based on Blueprint Classes. In UE4, you build an Actor with components, select it, and click the Blueprint / Add Script button (in the Details panel). Then, choose a place to save your Blueprint Class, and click Create Blueprint to save your new Blueprint Class!

Your new Blueprint Classes can be found in the Content Browser. You can Double-click to edit them directly, or you can drag and drop them into any level.

Where are Script Component and MonoBehaviour?

In Unity, you have Script Components that you drop on GameObjects to add C# scripting. You create a class that inherits from MonoBehaviour to define what that component does.

UE4 has something similar. You can create whole new Component classes of your own and drop those onto any Actor. You can create Component classes using either Blueprint Scripting or C++.

So how do you create your own component class in UE4? In the Details panel's Add Component drop-down, you see you can create new components, or choose existing ones:

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

In UE4, you will also be given a skeleton class with a InitializeComponent() function and a TickComponent() function, which perform functions similar to Start and Update.

If you create a Blueprint Script Component you will be given these same functions as visual nodes:

Scriptable Actor Blueprint Classes

Here is a cool feature in UE4: Your new Actor Blueprint Class can have its own Blueprint Visual Scripting! This allows you to 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, UE4 also supports C++ Classes implemented with code. Here is a side-by-side comparison of Unity and UE4 code, followed by an equivalent UE4 Blueprint.

Unity C#

UE4 C++

UE4 Blueprint

UE4 Blueprint Classes Can Be Extended

Unity prefabs and UE4 Blueprint Classes can be instantiated in your game similarly. However, Unity has complications related to nesting prefabs within other prefabs, which limit their role as extensible building blocks.

In UE4, 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, in UE4 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 which adds fire-breathing features), Grue (a Monster which is likely to eat you when it is dark), and for example 8 others. These subclasses of Monster all inherit the basic functionality from Monster, and add new capabilities on top.

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 have to go and update all 10 prefabs to individually copy and paste the new functionality into it.

In UE4, you can simply modify the Monster Blueprint Class to add this new ability to speak. That's all! Dragon, Grue, and the 8 other subclasses of Monster automatically inherit the new speaking functionality, and you do not need to touch them.

But there is more! Everything we have said here about Blueprint Classes also applies to C++ Classes, and everything is equally true of Actors and Components. These systems are designed to support large-scale development of extensible functionality, and can scale to projects with 10's or 100's of developers.

Using Blueprint Scripting, C++, or Both

Blueprint Visual Scripting is ideal for simple in-game logic flow and sequencing of actions. It is a great system for designers, artists, and visually-oriented programmers, because it is easy to access and control in-game objects visually. You can even create small standalone-game using just Blueprints; see the Tappy Chicken sample for a full-fledged example.

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, check out the Introduction to C++ Programming in UE4 page.

Most projects will use a mix of Blueprints and C++. Many developers prototype game functionality using Blueprints, because it is so easy and fun, 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 UE4 game development comes from the interplay between programmers implementing new features in C++, with designers and artists utilizing them in Blueprints and then asking for more! Here's how a team might structure a UE4-based shooter game implementing pickups using a mix of C++ Classes systems programming, and Blueprint Classes for behavior and appearance:

Transform Components

In Unity each GameObject has a Transform component, which gives the GameObject a position, rotation, and scale in the world.

Similarly in UE4, 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 is applied hierarchically to all components underneath it. 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, UE4 will create a 'Default Scene Root' for that Actor, which is just a plain Scene Component. If you drop a new Scene component in of your own, it will replace the Default Scene Root.

Compound Objects

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

In UE4, you create compound game objects by nesting components hierarchically:

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?

Its really up to you, but most often you will use a combination of custom component types along with Actor classes that use those components. We mentioned this earlier, but UE4 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.

Unreal Unity

There are several sub-classed Actor types you will quickly encounter in the engine and are useful in almost every type of game. Here is a list of our most common built-in Actors:

  • 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 that handle a lot of the complexity of those kinds of game objects.

  • 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 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 most common class used for gameplay in UE4 and the only type that can be Spawned into the World. So 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 will expect from a Unreal class, such as Reflection and Serialization. Object is a very basic class we use when we 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 this Gameplay Framework thing in UE4?

Okay, so this is where things get a little crazy (in sort of an awesome way.) Unity gives you a clean slate to start designing your game, and Unreal does the same. In Unity you can build everything out of basic GameObjects and components, and in Unreal you can build everything out of Actors and components.

However Unreal has this extra layer on top called the Gameplay Framework. This does not really exist in Unity at all. You do not have to use it in Unreal, but it is actually super cool! Basically, if you make use of some basic primitive classes and follow certain established conventions, your game will acquire some awesome features automatically that would be otherwise very difficult to implement or retrofit (such as full multiplayer support!)

Countless awesome games have been designed on top of Unreal's Gameplay Framework, and it is worth taking some time to understand how it works. Yes, you could roll your own version of this. That is totally fine if you want to! But hundreds of awesome Unreal developers have made great use of this framework in UE4 today, so it is worth taking some time to learn.

To use the Gameplay Framework, you really just need to learn the customized built-in Actor classes included with Unreal, such as Pawn, Character, and Player Controller, and eventually learn about how Unreal replication and networking features work. For now, let us get back to the basics though.

How to Write Code in UE4

For MonoDevelop Programmers

For Blueprint scripting, you will only need Unreal Editor -- everything is built in! To write code in C++, download the free version of Visual Studio on Windows, or install Xcode on Mac. When you first create a new project (or add code to an existing project), UE4 will automatically create Visual Studio project files for you. You can open Visual Studio by Double-clicking on a C++ class inside Content Browser, or by clicking the Open Visual Studio button in the main File menu.

One important difference in UE4: You will sometimes have to manually refresh your Visual Studio project files (for example, after downloading a new version of UE4, or when manually making changes to source file locations on disk.) You can do this by clicking Refresh Visual Studio Project in the main menu, or by Right-clicking on the .uproject file in your project's directory and selecting Generate Visual Studio project files.

Writing Event Functions (Start, Update, etc.)

If you are used to working with MonoBehaviors you are used to such methods as Start, Update, and OnDestroy. Here is a comparison between a Unity behavior and its counterpart in UE4 Actors and components.

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

But remember, in UE4 you can write code right on the Actor itself rather than only coding new component types. This is actually very common and useful.

Similar to Unity's Start, OnDestroy, and Update functions, we have a similar set of methods for Actors in UE4:

C++ :

Blueprint :

Components in UE4 contain different functions. Here is a simple example:

C++ :

Blueprint :

Remember, in UE4 it is important to call the parent class' version of method.

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

You may have noticed some things begin with 'A' and others with 'U' in C++. The prefix 'A' indicates an Actor sub-class. Where as the prefix 'U' indicates an Object sub-class. There are some other prefixes too, for example 'F' is used for most plain data structures or non-UObject classes.

Writing Gameplay Code in UE4

Okay, things are going to get a bit deeper from here on out. We will be talking about programming topics that are critical for creating games. Because you know Unity, we will be explaining features with slant toward C# users learning Unreal C++, but you can use Blueprint Scripting for pretty much everything if you want! We have added examples in both C++ and Blueprint where possible.

Let us talk about some of the most common gameplay programming patterns and how you would approach them in Unreal. Many functions in Unity have a comparable function in Unreal that should seem familiar. We will go through the most common functions one by one.

Instantiating GameObject / Spawning Actor

In Unity, we use the Instantiate function to create new instances of objects.

This function takes any UnityEngine.Object type (GameObject, MonoBehaviour, etc.), and makes a copy of it.

In UE4, there are a couple different functions to instantiate objects, depending on your needs. NewObject is used for creating new UObject types, and SpawnActor is used for spawning AActor types.

First we will briefly talk about UObjects and NewObject. Subclassing UObject in Unreal is much like subclassing ScriptableObject in Unity. They 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 may instantiate it like this:

And in Unreal, if you created your own UObject derived type, you may instantiate it like this:

So what about Actors? Actors are spawned using the SpawnActor method on a World (UWorld in C++) object. How do you get the World object? Some UObjects provide a GetWorld method for you, as an example, all Actors do.

You will notice 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.

But what if you want to make a 'copy' of another object, like what Instantiate allows you to do?

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

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

In the above example, 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.

In the constructor of AMyActor, we have set the default property values for the class. Note the use of the CreateDefaultSubobject function. We can use it to create components and assign default properties to them. All the subobjects we create using 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#:

UE4 C++:

Destroying GameObject / Actor

Unity

C++

Blueprint

Unity

C++

Blueprint

Unity

C++

Blueprint

Unity

C++

Blueprint

here.

RayCast vs RayTrace

Unity C#:

UE4 C++:

UE4 Blueprint:

Click for full view.

Triggers

Unity C#:

UE4 C++:

UE4 Blueprint:

You can read more about setting up collision responses here.

Kinematic Rigidbodies

Unity C#:

In UE4, 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.

UE4 C++:

Input events

Unity C#:

UE4 C++:

UE4 Blueprint:

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

You can read more about how to set up input here.

Unity Unreal Engine

FAQ

How do I load my last project automatically?

If you are used to Unity automatically loading the last project you were working on, the same is possible in UE4. To enable, check 'Always load last project on Startup' when opening a project. You can also toggle the setting at any time from the main Edit menu under Edit/Editor Preferences/Loading and Saving/Startup.

Where do I set Input Bindings for my game?

In Unity, you are used to using the Input Manager settings for Project to setup default bindings. In UE4 it works similarly. You will open your Project Settings then select the Input category. There, you can add various buttons (actions) and analog controls (axes). Give each control a name and default binding. Then, you can get callbacks to your game's Pawn when the input events are triggered. Check out the Input documentation page for the details.

How do I change the starting scene of my project?

You can change the startup map of your project from the project settings tab. From the main menu choose Edit/Project Settings->Maps & Modes to change the starting map.

How do I run my game?

The easiest way to run your game is to click the 'Play' button on the the main editor toolbar, which will run the game right inside the editor's process. If you want to run it as a standalone application, click the dropdown arrow next to 'Play' and choose 'Standalone Game'. Finally, if you want to run on a mobile device or in a web browser, you will use the 'Launch' button on the toolbar (after installing any prerequisites that are needed for that platform.)

What units are these?

In Unity, the primary unit of measurement is one meter. In UE4, 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 UE4.

If you want to move something 2 Feet in Unity that would be 0.61units (meter) and in UE4 is 61 units (centimeters).

What is with this coordinate system? Which way is up?

Both Unity and UE4 use a left-handed coordinate system, but the axes are swapped around. In UE4, positive X is 'forward', positive Y is 'right' and positive Z is 'up'.

How do I see Log Output from my game?

In the UE4 editor, you can open the 'Output Log' from the 'Window -> Developer Tools' menu. You can also run your game with the '-log' command-line parameter to summon a dedicated log window alongside your game, which is really useful!

Unity Download

Speaking of Log Output, where is my Debug.Log?

Logging in UE4 is highly customizable. Read up on how to log messages here.

Unreal Unity

How do I throw exceptions?

In Unity, you are used to throwing exceptions when things go wrong. UE4 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, UE4 does not use the .NET framework. UE4 has its own set of container classes and libraries. Common container comparisons:

.Net Framework

UE4

Unreal Engine Or Unity

Yes! You can leave the editor open while you write code. Simply kick off a compile from Visual Studio after you have finished editing code, and the editor will 'hot reload' your changes automatically. You can also click the Compile button on the editor's main toolbar. That can be useful when you have the Visual Studio debugger attached.

Where To Go From Here

Unreal Unity Comparison

Thanks for reading the guide! This was created for the Unreal community with the help of Unreal developers everywhere, and we very much appreciate any feedback and corrections you can offer. We will try to keep improving this document as we learn more about what is most helpful when transitioning to UE4!

We have many additional UE4 learning resources available!

Unreal Or Unity

  • Documentation

    • Getting Started - Basics/GettingStarted

  • Tutorial Videos - Videos

  • API - API

  • AnswerHub - https://answers.unrealengine.com

  • Forums - https://forums.unrealengine.com

  • Wiki - https://wiki.unrealengine.com

    • Wiki page about learning UE4 coming from Unity