In Spawning Projectiles is confusing

All i understand from this lecture is that we created a c++ variable “ProjectileClass” based on type AProjectile (which is c++ class not Blueprint class) Then we SpawnActor of Type same as AProjectile but different UClass " ProjectileClass" which has same type AProjectile Then we set that Projectile Class to “BP_Projectile” why ?it’s so confusing for me cause I’m thinking it in very different way :{

To understand the context, would you mind sharing what lecture you’re on?


Section 5:ToolTank

So we create a new actor class called AProjectile that has a static mesh and later on additional components.

We then create a variable called ProjectileClass that is of type TSubclassOf<AProjectile>. TSubclassOf<> is a wrapper around a UClass which stores the reflected metadata for some type, you don’t need to know too much what that means as we’re using that to effectively store a type in a variable. TSubclassOf<> allows you to specify the type you wish to allow which allows it to provide type safety and the ability for the editor to filter out unrelated types when you go to assign it. - More info

We then create a blueprint out of that class to be able to set the static mesh (and later other properties), this also allows you to quickly edit properties without needing to recompile the code.

When it comes to spawning it we pass in ProjectileClass which has been assigned to the blueprint class. If you didn’t use this (.e.g. used AProjectile::StaticClass() directly) then you would be spawning a projectile without any of the properties set.

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

Privacy & Terms