Why do we keep repeating stuff like SceneLoader sceneloader;?


As I’m going throughout this course, I keep on getting confused as to why we keep on doing stuff like:

SceneLoader sceneloader;
Level level;
Vector2 paddleToBallVector;

etc… Is it because we’re calling classes, then labeling them to use in the code?

Update, I’m understanding it now.

It’s used to call another script, then we use the variable that we called the script with to ask for other methods from other scripts. Like level._______().


When we declare a variable, we need to define a type. Instead of being creative, we simply name our variable after the class when the class name is self-explanatory. We do not have to distinguish between individual variables of type SceneLoader in this class.

Vector2 is not that self-explanatory. We know that the object contains two float components but we do not know what purpose it has in the context of our class just by reading Vector2 vector2. For this reason, we give it a more meaningful name like paddleToBallVector.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.