I wouldn’t just smack down his approach. Sure, it’s tedious, but his question implies that he dived right in and at least understood something.
Let him go at it and then decide himself when he needs a more structured approach to learning. In fact, doing a course on something is easier once you tried that something.
I’d just suggest doing the course early, rather than late, to avoid acquiring bad habits. Your first attempts at code will look atrocious to you, once you actually learned how to code.
Anyway, for the OP question:
A function is a set of instructions that can be inserted at any time into a piece of code.
For example, if you want to compare two numbers, you call the function for comparing two numbers.
Most of the time it follows a syntax like “Compare(Number1, Number2)”. The actual comparison operator in C++ is ==, but that’s beside the point right now.
As you can see in the example, you input two numbers and then… Yeah, how do you get the result?
By doing stuff like this:
bool result; //Declares a boolean (true/false) variable called result
result = Compare(3, 5); //sets result to the result of the Compare function
This is where the “void” thing comes into play. “Compare” used bool instead of void, which means that the return value will be a boolean.
This means you can use the function like a number. You can set the value of a variable to the result of the function.
Have you seen the instruction “return XYZ;” in any of the functions you looked at?
Once that instruction is called, the function ends and its output value is set to the value that is written after return.
int PassThrough(int Pass) {
return Pass;
}
Is a valid function. It doesn’t do anything useful, though. Writing “x = 1” and “x = PassThrough(1)” would be the same.
Functions that use void are called procedures. They don’t output anything, but rather do something. In your example, it’s used for Events. Tick is an Event that is called once per tick (internal time unit of the game) and BeginPlay happens once after the actor with that Event is created in the game world. (There’s also the constructor, which describes how the actor is created. Constructors are an object-oriented concept that you should look up once you got the basics down)
There’s also keywords like virtual and static, but I suggest you learn how to Google this kind of question. Seriously, half the point of having a second monitor as a programmer is to have Google open while you code.