And the class whose static function I want to call is stored in the variable CurrentProjectile. Can I call that static function through the variable CurrentProjectile?
You should be able to just do CurrentProjectile::OnFire(), since you are declaring that to be a subclass. Does this not work? Static functions are not called on instances, they are called from the class itself.
But my variable ( TSubclassOf CurrentProjectile) stores a blueprint class rather than the c++ class. I want to call the static function of that blueprint class.
I see… that’s not how statics work, as they have no runtime polymorphic behaviour.
It looks like you’re trying to make a factory for projectiles of a certain type?
Rather than have a static function on your projectile classes, why not spawn a projectile of type CurrentProjectile and then call a virtual function on it to set it up appropriately?
If you take a look, our AI tests do something similar with pawns (UE4/Engine/Source/Developer/FunctionalTesting/Classes/FunctionalAITest.h).
FAITestSpawnInfo has a variable called PawnClass, which is used with UWorld::SpawnActor to spawn an object of the correct type. This sounds similar to what you’re trying to achieve with your projectiles, eg).