Could I get some clarification about spawning actor classes?

I have some doubts regarding spawning an actor.

I read https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Actors/Spawning/index.html
but still got a few doubts.

World->SpawnActor<AMyProjectProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);

E.g. here is a code from the 1st person shooter sample.

Here AMyProjectProjectile is the class of the actor which is spawned. What is other ProjectileClass here?

From the FPS C++ tutorial:

UPROPERTY(EditDefaultsOnly, Category=Projectile)
TSubclassOf<class AFPSProjectile> ProjectileClass;

If you look at the blueprint for your projectile that you will be creating, there should be a ‘Projectile’ section where you are able to set the class to be used. Or you can look into loading the class/blueprint in your constructor.

Ya i have seen that…

But my doubt is, in

    World->SpawnActor<AMyProjectProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);

If ProjectileClass is the variable whose actor is spawned, then what is ?

It’s a class reference (not object instance), so engine know which class of object to spawn, and as dune suggests it is a property you can set in blueprint in classes related to it where you pick which class of projectile to spawn.

AMyProjectProjectile is in so called template, it makes spawnactor funtion return instance or that class insted of actor class which it does by default (withou this template). It also sets type of first argumet of that funtion so you cant place refrence of parent classes which may not be able to be casted to target classs in template.

And ProjectileClass is a refrence of class varable which conatins info of class thet needs to be spawned and is a child of AMyProjectProjectile because templated set before thet force you to. C++ does not support class refrenceing, you can’t keep class type in varable, there for UObject system in engine got pseudo solution for that which is UClass class which is refrence of a class, ID card of class you could say, so classes is identified by the engine by collection of uclass objects. Thanks to that you can place class refrence in to varable or put it in funtion argument like in this case. You can get class refrence of any UObject releted class by this statment ASomeActorClass::StaticClass ()

Sorry I mistyped my previous question. I mean to ask the difference between

AMyProjectProjectile

and

ProjectileClass

And which class of actor actually spawns? And why do we need to mention both of the classes.