Initializing TSubclassOf

I’m trying to initialize

const TSubclassOf<UActorComponent> Component = ______;

to an actor component I have called “Obstacle”.

I tried using the class name, UObstacle, but to no avail.

It worked. Thank you :slight_smile:

Try UObstacle::StaticClass()

TSubclassOf is template type of UClass* which limits class selection to specific relation but with cast overload magic it works as same as UClass*. UClass object is representation of class in reflection system and each UObject class has UClass object created for them during code module initiation. You can access UClass* of specific class as MrMcKvarz suggests using static function StaticClass() that is in any UObject class.