View Full Version : LocalPlayerControllers iterator problem
LagMasterSam
11-21-2007, 12:56 PM
When I try to use the LocalPlayerControllers iterator, it does not seem to be finding any local PlayerControllers.
simulated event PostBeginPlay()
{
local PlayerController PC;
Super.PostBeginPlay();
LogInternal("*** POST ***");
ForEach LocalPlayerControllers(class'PlayerController', PC)
{
LogInternal("*** LPC ***");
if ( UTHUD(PC.MyHUD) != None )
{
UTHUD(PC.MyHUD).AddPostRenderedActor(self);
LogInternal("*** ADDED ***");
}
}
}
*** POST *** appears in the log but *** LPC *** does not.
KewlAzMe
11-21-2007, 01:02 PM
I thought I saw "AllControllers" somewhere. Maybe try that.
Mysterial
11-21-2007, 01:07 PM
Where is this code? You may be calling it before the local player is intialized (for example, if that PostBeginPlay() is in a Mutator, the player won't be there)
LagMasterSam
11-21-2007, 01:15 PM
Where is this code? You may be calling it before the local player is intialized (for example, if that PostBeginPlay() is in a Mutator, the player won't be there)
This code is in an Actor that gets spawned by the CheckReplacement() function in a mutator. I guess that explains the problem. :)
What would recommend for solving this problem? I need to call UTHUD(PC.MyHUD).AddPostRenderedActor(self). Is there another function "after" PostBeginPlay() that would work?
Mysterial
11-21-2007, 01:53 PM
This code is in an Actor that gets spawned by the CheckReplacement() function in a mutator. I guess that explains the problem. :)
What would recommend for solving this problem? I need to call UTHUD(PC.MyHUD).AddPostRenderedActor(self). Is there another function "after" PostBeginPlay() that would work?
Just check it in the first tick. Either add a flag for whether you've already checked it or put it in a special state for the first tick.
LagMasterSam
11-21-2007, 06:49 PM
Hmm. Using a special state for the first tick sounds like a good idea since I need to use the tick() function anyways. Thanks a lot Mysterial.
Powered by vBulletin® Version 4.1.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.