Flash
In Flash, we simply created the grid using the drawing tools. Vertical and horizontal lines, using a hairline stroke, spaced 20 units apart, covering the entire scene:
In the ActionScript of our Actions layer, we added a couple of functions that will be called by UnrealScript. The first will show/hide the grid, the second will scale it. We hide the grid initially to make positioning easier:
function GridToggle()
{
GridInst._visible = !GridInst._visible;
}
function GridZoom(Param1:Number)
{
GridInst._xscale = GridInst._xscale + Param1;
GridInst._yscale = GridInst._xscale;
GridInst._x = stage.width*.5 - GridInst._width*.5;
GridInst._y = stage.height*.5 - GridInst._height*.5;
}
GridInst._visible = false;
From now on, whenever you make a change to the HUD you must:
- Publish the movie
- Open the UDK Editor and reimport the movie into your package using the Content Browser.
- Save the package
- Copy the package from the UDKGame\Content\Misc folder to the UDKGame\CookedPC folder.
BattleMapGfxHud.uc
Add two wrapper functions for the ActionScript functions above:
function CallGridToggle()
{
ActionScriptVoid("GridToggle");
}
function CallGridZoom( float Param1 )
{
ActionScriptVoid("GridZoom");
}
BattleMapPlayerController.uc
All we need to do here is reference a new Input class that we're going to create to interpret keyboard/mouse commands. Add this to the DefaultProperties section:
InputClass=class'BattleMap.BattleMapPlayerInput'
BattleMapPlayerInput.uc
This is a new class that will call our wrapper functions based on input events. I arbitrarily chose a delta of 5.0% when scaling the grid:
class BattleMapPlayerInput extends UTPlayerInput within BattleMapPlayerController;
var float GridZoomDelta;
exec function BMGridToggle()
{
BattleMapHUD(myHUD).CrossHairMovie.CallGridToggle();
}
exec function BMGridZoomIn()
{
BattleMapHUD(myHUD).CrossHairMovie.CallGridZoom(-GridZoomDelta);
}
exec function BMGridZoomOut()
{
BattleMapHUD(myHUD).CrossHairMovie.CallGridZoom(GridZoomDelta);
}
DefaultProperties
{
GridZoomDelta = 5.0f
}
I know. We seem to have a lot of functions just calling each other. Here's the flow:
Input Event > PlayerInput > GFxMoviePlayer > ActionScript
DefaultInput.ini
Lastly, we need to specify what keyboard/mouse events will trigger those actions. In UDKGame\Config\DefaultInput.ini, scroll all the way down past "Editor Bindings". Add a new section:
;-------------------
; BattleMap Bindings
;-------------------
.Bindings=(Name="BMGridToggle",Command="BMGridToggle")
.Bindings=(Name="BMGridZoomIn",Command="BMGridZoomIn")
.Bindings=(Name="BMGridZoomOut",Command="BMGridZoomOut")
-Bindings=(Name="G",Command="GBA_SwitchToBestWeapon")
-Bindings=(Name="MouseScrollUp",Command="GBA_PrevWeapon")
-Bindings=(Name="MouseScrollDown",Command="GBA_NextWeapon")
.Bindings=(Name="G",Command="BMGridToggle")
.Bindings=(Name="MouseScrollUp",Command="BMGridZoomOut")
.Bindings=(Name="MouseScrollDown",Command="BMGridZoomIn")
This is doing three things:
- Maps Input Binding commands with UnrealScript (PlayerInput) functions (I just happened to have named them the same)
- Unbinds previously specified inputs from their default commands
- Binds those inputs to our new commands
The result is:
For reference, to implement this just using the UDK and UnrealScript, we had to:
- Paint a grid texture
- Model a grid mesh (essentially, a 2D plane)
- Create a BattleMapGridActor in UnrealScript which instantiated the grid mesh, applied the texture, and included several functions for moving ("scaling" by moving up and down, and positioning horizontally)
- Include numerous functions in BattleMapPlayerInput for spawning, moving and snapping the grid
Where does the flash file come in? How do you associate the swf file with our package? I have top-down working, but no mouse movement or character rotation.
ReplyDeleteThe flash file is referenced in BattleMapGfxHud.uc. (See the previous post.) That shows how to connect the mouse's movements in ActionScript to UnrealScript.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteWhat exactly is in your HUD? Is it just the BIG mouse pointer and the line from the Pointer and the Player? Or is it the Green Information system up in the top left of the Screen? Or both?
ReplyDelete