Learning UE4 C++ coming from Unity C#

Hello,

In Unity, the process generally is to build object hierarchies in the editor, and add logic as components. These hierarchies are saved as prefabs usually. The components hold virtually all of the game code.

I assume Unreal Actor and Unity GameObject are effectively equivalents between the two frameworks, but you cannot subclass GameObject in Unity. It exists merely as a container of components and high level object manipulation.

It seems that most Unreal engine tutorials have you subclassing and adding logic directly to Actor descendants.

Is it more encouraged to subclass and code directly into the classes rather than make components in Unreal? Are there any other important differences that would make it unwise to use Actor in the same way as GameObject?

Is it all personal preference? I’d love to hear what your preferred workflow is at a high level, or if there are any gotchas associated with certain workflows.

Thanks

I recommend to build hierachies using C++ by deriving from the existing classes (Actor, ActorComponent, UObject should be enough for the first steps). In UE4, your prefabs are basically either blueprints or C++ classes. I prefer to use C++ only and rely on blueprints just for UMG. If I want to be able to set variables from within the editor, I build blueprints which inherits from my C++ class (e.g. for PlayerController).

The concepts of prefabs in Unity is really great from the user perspective. UE4 doesn’t provide such a unified concept.

Thank you for the response, that seems like a pretty manageable way to work.

There is a Unity to UE4 Guide up that will probably help you.

My typical workflow is: 1) create reusable Actors using C++, Blueprint or both. 2) place those Actors on the level. The Component system in Unreal is just one step deeper in terms of reusability. :slight_smile: It allows you to first create reusable Components and then build your Actors out of these Components. TLDR: Actor is a building block of a level, Component is a building block of an Actor. Whether to use or not use Components is completely up to you.