Download

Meta: How to approach new programming tasks as a newbie?

Hello, I am learining Unreal C++ API. I have been struggling with NewObject(): my objects were not displayed in viewport, but were visible in the WorldOutliner. Finally after hours of effort i have stumbled upon an example on Unreal Forums that I need to call RegisterComponentWithWorld() on new objects.
I usually search Unreal Forums, look for some youtube tutorials, look at the Docs and official unreal tutorials, but sometimes its just not there and I loose hours…
Am I missing something? What is the “proper way” of going about this?

There is a little shortage of some of the fundamentals. I’d like to see more examples in the API documentation for common stuff like adding components etc, especially as the preferred/required syntax can change with versions.

Best answer I can give is try the Unreal Slackers Discord channel, there’s loads of people online who can help you with simple stuff like that very quickly.

Download the C++ examples and use those as reference. That is what I used. Like the Strategy Game or Shooter Game.

They are a bit too “fancy” for real C++ beginners. Too much code when all you need is a simple unambigous example of something.

There is no “proper” way. Everyone has their own methods, a lot of developers usually Google for hours sometimes days looking for a tiny bit of code that works properly. The amount of time you spend on this definitely depends on your searching skills; using the right words will get you exactly what you want. I spend about 1 minute on Google only to find this: How to create a simple object in C++ with UE4? - UE4 AnswerHub, which is most like what you’re looking for (not NewObject() which works but, depending on your parent class, needs a mesh component to render properly).

It actually sounds like you need to understand the architecture of UE4; how the scene graph hierarchy works, how components work and why they exist, etc. In UE4 (and in a vast majority of game engines) an object isn’t something that’s necessarily rendered to screen, it’s something the engine can reference in memory, garbage collect, etc. Objects can have components, a lot of the objects you’re used to (the rendered ones) have a mesh component and a root transform component that tells the engine the scale, location, rotation, skew of the mesh (brush up on matrices, especially homogeneous/4x4 matrices).