Hello everyone! I just downloaded UE4 and I’m really excited to start making some games!
Before I begin digging through tutorials and reverse-engineering the free content, I wanted to ask the community some basic questions just to get a feel of what i’m jumping into.
A bit about my background first though: I consider myself a level designer with some programming experience. The first engine I used was UDK but I struggled with Uscript so I mainly used Kismet to create interactivity and gameplay. I then began using Unity and found that I was quickly picking up C# (after about 2 weeks I understood the basics of the language). I’ve been programming in C# for about 6 months now and I’m definitely not an expert but I can at least make things work and I’m confident that I know enough to make an entire game (even if my code isn’t as beautiful as someone with as computer science background). I’ve even been the sole programmer on a few different Unity projects. I mainly lack finesse when it comes to programming (Like how to use delegates,event handling, how to optimize for performance and things like that), but I fully understand the basics by now like if statements, most of the variable types and their uses, loops, calling functions and passing arguments, etc.
Anyways, my question is how similar is C++ to C#? Would someone with a basic working knowledge of the C# language be able to pick up C++ fairly quickly or is this a completely different beast? I took a quick look into some example code and already noticed some unfamiliar things like header files and the UProperty() function. I’m just curious on your thoughts and what I’m up against. Has anyone been in a similar situation?
Thanks! looking forward to hearing from everyone and being a part of this community.
C# was basically Microsoft’s answer to Java. The syntax isn’t really too different but there is a difference.
public static void main(String] args) is replaced with int main()
But in UE4 you’ll be focused with the (what feels like infinite!) libraries that the engine uses along with C++'s libraries.
What separates C++ from any other language can really be boiled down to one word: Pointers. Pointers are probably the most powerful tool you’ll ever use in programming. Direct memory access.
So learning pointers is an absolute must. UProperty is linked to the engine.
I looked up what libraries are and I think I understand (I apologize for my ignorance if this is a common-knowledge term/concept).
So libraries are scripts that are pre-built with some commonly-used methods and you as the programmer can easily access these methods?
As for pointers, I’m not really sure I understand their purpose. It seems like they are just constant variables? I’ll have to look into it more and check out some tutorials to understand.
Pointers allow you direct memory access. Whether it’s referencing or changing the values from someplace else. They are not constants by default.
C++ is a widely used language and a really, really long lasting one at that. Again it’s all thanks to pointers. In many cases, in games (Especially with UE4) there will be instances where you’ll want to reference a particular item, enemy, weapon or something in the world. You’ll do this with pointers.
For instance i’ve made quite a few threads about Ray-Casting and it’s importance. By referencing the objects my Ray hits, I can acquire just about every bit of information from it or send information to it.
Pointers separate the C++ wannabe to the C++ guru, as most C++ programmers will tell you. No problemo, happy to help.
C# can use pointers in “unsafe” context to a certain extent as well. What really separates the languages is C++'s (IMHO a bit antiquated) use of includes and templates. Unreal Engine code makes much use of these features (yes, and also of pointers), so learning C++ is still a bit different from learning to read and write Unreal Engine native code.
Here is a linkto an article on C++ for C# programers. The actual article is a PDF document that’s linked at the bottom.
UPROPRETY() is a macro, not a function. Macros are compile time text replacement that can be used for repetitive boiler-plate code. UE4 uses it for implementing Blueprint, among other things.
Actully UPROPERTY, UFUNCTION, UCLASS, USTRUCT, UENUM etc are dummy macros, they are empty and ignored in compile time. They are used as markers for UHT (run before compile) which generate header files which exposes things to engine features (not only blueprints :p).
I didn’t realize that they were dummy. I’ve been looking at Slate which does use macros (SNew,SLATE_BEGIN_ARGS, etc) for boilerplate and assumed the UOBJECT stuff worked the same.
Thanks everyone for the replies! It seems I have a bit to learn if I want to be considered a serious programmer. I’ve just started watching the unreal programming tutorials today, and I’ll definitely check out that article, so thanks jcoder for that link!