Hey all,
This is more of a rant, but I am interested in some workarounds.
I’ve been running into an inconvenience in Unreal when it comes to local scope. C++ in particular, doesn’t like say Player being defined in a class and then later as a parameter in a function. Kind of annoying, since local scope should provide some flexibility.
Like:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "References")
class ASQPlayer* Player;
UFUNCTION(BlueprintCallable)
void AddPlayerToActiveList(ASQPlayer* Player);
The above is not allowed because of shadowing restrictions. That’s annoying, since the one in local scope (or function scope) shouldn’t create ambiguity.
So, then player lower case is doable since case sensitivity is a thing. I know a lot of programmers like to use underscores _player
or dashes -player
for this. However, UFUNCTIONs get even pickier. If two functions share the same variables in the parameter list, it’ll also throw an error.
Is it just me, or does it get exhausting when trying to write functions and having to come up with a unique name for every new instance of a variable? It’s local scope, it shouldn’t matter.
Here are some examples:
Fine in C++ if not a UFUNCTION
void AddPlayerToActiveList(ASQPlayer* player);
void RemovePlayerFromActiveList(ASQPlayer* player);
void AddActionToActionQueue(ASQPlayer* player, ASQPlanet* planet, EBuildingTypes buildingType, int buildTime);
If a UFUNCTION, it gets angry…
UFUNCTION(BlueprintCallable)
void AddPlayerToActiveList(ASQPlayer* player);
UFUNCTION(BlueprintCallable)
void RemovePlayerFromActiveList(ASQPlayer* player);
UFUNCTION(BlueprintCallable)
void AddActionToActionQueue(ASQPlayer* player, ASQPlanet* planet, EBuildingTypes buildingType, int buildTime);
I guess in this case, I could do “PlayerToAdd” and 'PlayerToRemove" but I shouldn’t have to. How do you deal with this? I’d rather not have to make a unique name every time I need a temporary variable for something.