Download

Event for when the locally controlled player controller is assigned?

I want to spawn a class when my player controller is assigned, but only if it’s locally controlled.

However you’re not able to call IsLocalPlayerController() during PostBeginPlay() in player controller.

Can anyone think of an event/function that would be appropriate for this?

Cheers

In PostBeginPlay() can you set a timer to call a function later? In that function you can see if IsLocalPlayerController() is working yet. If so, check to see if you need to spawn your thing. And if IsLocalPlayerController() is not yet available, reset the timer and try again.

Thanks for the response @Nathaniel3W. That is actually how I’m doing it at the moment. However I see it as a bit of a hack. I’d prefer it to be event driven if possible.

In case this helps anyone, I started using:



//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Called after this PlayerController's viewport/net connection is associated with this player controller.
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
simulated event ReceivedPlayer()  { }


in PlayerController.uc. Works fine for both authorities and clients.