SuggestProjectileVelocity question

I am working on Battle Tank, and at this particular lesson, that uses SuggestProjectileVelocity method, I am a bit confused. So my question is:

I know I have to #include "Kismet/GameplayStatics.h" at the top. But why do I have to include the class name when calling it like this: UGameplayStatics::SuggestProjectileVelocity(...) ? It always spits out error when compiling if I don’t include the class name. Then what is the point of #include anyway? Can’t I just call SuggestProjectileVelocity(...) only, once I have #include "Kismet/GameplayStatics.h" ?

If someone can explain this clearly, I’d really appreciate.

Because it’s a static member function of that class.

So the compiler knows what that is. Without the include the compiler is going to say “What is UGameplayStatics?” It has no idea what it is without the include.

No because it’s an different class, it’s not in the current scope.

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

Privacy & Terms