Spawn actor from const UClass*


the struct FMovieScenePossessable returns me a const UClass*:

const UClass* GetPossessedObjectClass() const

Is the only way to spawn an actor from this class a const_cast? There is no version of GetWorld()->SpawnActor that takes a const UClass*. But NewObject<> does have one. Can I use NewObject<> instead and if yes, how can I use it so that I get the same result as with SpawnActor?


One thing you can use - cast to remove const

const UClass* constPtr;
auto notConstPtr = const_cast(constPtr);

In common case, it is rather tricky to execute all the logic of SpawnActor with NewObject<> because of internal flags and scope parent links.