Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.6\Engine\Source\Runtime\CoreUObject\Private\Templates\Casts.cpp] [Line: 11]
Cast of Class /Script/TemplatePlatformer.APlayerController to Level failed
UE4Editor.exe has triggered a breakpoint.
UE4Editor.exe has triggered a breakpoint.
I don’t have the code in front of me but spawning components and other UObjects uses ConstructObject. I think the Unreal Tournament source code has a lot of examples of doing this. One thing to keep in mind with spawning components is you still have to register the component manually I think after it’s spawned, otherwise you won’t see the static mesh in the world or whatever it is you spawned.
Yes. But there’s a lot more to adding a new controller than just creating the object… There’s a bunch of registration and management happening behind the scenes as well as many related classes.
The default, single controller behaviour has suited us fine for now so I don’t know a lot about how multiple controllers would be done, but I know it should likely be in AGameMode. Look at AGameMode::Login and AGameMode::InitNewPlayer in particular and where those are being called. It looks like UGameInstance::CreateLocalPlayer calls those as needed and would probably be your best starting point.