Accessing unreal script variables from Kismet - UDK

1k Views Asked by At

I have almost 0 scripting experience with UDK, but I think what I'm trying to do is fairly simple. I want to define a variable in script that I can then access in Kismet.

This is what I have so far:

MyGameInfo.uc looks like this

class MyGameInfo extends UDKGame;

defaultproperties{  
    PlayerControllerClass=class'MyGameInfo.MyPlayerController'
}


event InitGame( string Options, out string Error )
{
    // Call the parent(i.e. GameInfo) InitGame event version and pass the parameters
    super.InitGame( Options, Error );

    // Unreal Engine 3
    `log( "Hello, world!" );
}

MyPlayerController.uc looks like:

class MyPlayerController extends UDKPlayerController;

var() localized string LangText;

defaultproperties{
   LangText="asdfasdf";
}

Then, in Kismet I'm using Get Property, with player 0 as the target, attempting to get property LangText. I have the string output going to Draw Text (and yes, I made sure to set a font).

It looks like this: Kismet screenshot

I feel like I'm really close, but no text shows up in the Draw Text. Any ideas?

Also, why am I trying to do this? For localization purposes. As far as I can tell, there's no easy way in Kismet to use localized strings for Draw Text. My thinking is just to create a localized string for each piece of dialog and then call those strings from Kismet as needed.

1

There are 1 best solutions below

0
On

You need to make sure you added a Font asset from the content browser in the DrawText properties, and check it is actually placed on the screen (try Offset 0,0 for centered text) Also, I think that DrawText doesn't work in UTGAME - in case that's your gametype. It works in UDKGame. And if you have ToggleCinematic mode enabled, then check Disable HUD isn't on.

Test the DrawText with a regular string first...

Try using Player Spawned event instead of Level Loaded, as it may fire too fast for the player to have been added in the game yet.