PDA

View Full Version : Can't access classes from custom class?



Xerces
03-19-2010, 07:45 PM
I created a class MyKActorSpawnable (extending KActorSpawnable). KActorSpawnable extends KActor extends DynamicSMActor extends Actor. Actor has a function "native final function PlayerController GetALocalPlayerController();" which I assume returns the currently set default player controller which was set from DefaultGame.ini.

In my class, I can call the function, but can't do something like


PlayerController c = GetALocalPlayerController();


I get an error saying it doesn't know what PlayerController is. What I want to do is cast "c" to MyPlayController, but it doesn't recognize MyPlayerController as a valid class either. MyPlayerController is in the same directory as MyKActorSpawnable, so I don't see why it can't find it. Any idea why I can't access this class?

Mr Evil
03-19-2010, 07:55 PM
1) Local variables must have the "local" specifier.
2) You can't declare and assign a variable in one line.

Therefore, try this:

local PlayerController c;
c = GetALocalPlayerController();

Xerces
03-19-2010, 07:56 PM
Thanks for the tip! I also solved my problem. Just after posting I remembered seeing a "dependson" keyword before. Adding dependson(MyPlayerController) to the class declaration solved it.

Blade[UG]
03-19-2010, 10:22 PM
GetALocalPlayerController() does not return a class, either .. it returns an instance of a local playercontroller .. which, for most people, is the one running playercontroller.. but the function is useless in a multiplayer game, so keep that in mind. So, as long as you are specifically a single player game, that function will give you the one running player controller.. but if you're multiplayer, network or local, it will act differently.