Tuesday, October 9, 2012

Cookbook: actionscript -> kismet commands with parameters

At some point in your project, you'd like to create some nice menu and be able to load different levels, setup resolutions, etc. Let me show you the way how to simply do it and additionally use utilize parameters as well.



For my demo installer I needed some simple menu (possibility to choose from a set of levels and change resolution for older HW/notebooks). I didn't have much time to play with Scaleform and so I've chosen actionscript 2.0 approach that was more familiar to me. Easiest way to send a string command to unreal is by using fscommand.


   1:  buttonLevel[i].onPress = function() {
   2:              //command to be linked with kismet node
   3:                         //actual command we want to run in kismet
   4:     fscommand("loadmap","open " + levelNames[this.id]);
   5:  };


This method can additionally have a string of parameters that can be parsed/used in kismet to avoid necessity to creating separate kismet nodes for generic tasks (e.g. open level1, open level2, ... open level37). If you're curious how to react on such a command on unreal side, utilize kismet event node FsCommand (New Event/Gfx UI/FsCommand). This node has an optional argument that can be sent to any other kismet action (e.g. Console Command for opening levels).




FsCommand node requires its parameter fsCommand to be set to string that links it with actual fscommand sent from action script.

So in our case for example for opening levels we send fscommand from scaleform with argument (easier to compose it in actionscript than in kismet) that is the actual command to run in kismet and in kismet we just link this string argument and use it in another kismet action. Nevertheless we are sufficient with simple kismet node setup without the necessity to create a separate scheme (and devise separate command names) for each new level to load/resolution to set, etc.

No comments:

Post a Comment