Sunday 26 June 2011

Code and custom binding

I was supposed to post some environment sketches but soemthing big happened during this week and I had to start working on my game. 

So I'm using a azerty keyboard when the rest fo the world use a qwerty one. So look into key binding in-game to remap the key. After looking for hours I finally found out how to do so; 

exec function GoQwerty()
{
local name key01, key02, key03, key04;
key01='a';
key02='w';
key03='q';
key04='z';
PlayerInput.SetBind(key01, "GBA_StrafeLeft");
PlayerInput.SetBind(key02, "GBA_MoveForward");
PlayerInput.SetBind(key03, "GBA_ToggleTranslocator");
PlayerInput.SetBind(key04, "GBA_ShowCommandMenu");
`log("Qwerty keyboard");
}

exec function GoAzerty()
{
local name key01, key02, key03, key04;
key01='q';
key02='z';
key03='a';
key04='w';
PlayerInput.SetBind(key01, "GBA_StrafeLeft");
PlayerInput.SetBind(key02, "GBA_MoveForward");
PlayerInput.SetBind(key03, "GBA_ToggleTranslocator");
PlayerInput.SetBind(key04, "GBA_ShowCommandMenu");
`log("Azerty keyboard");
}
that's a easy way to do then you just nneed to press tab in game and type one of the command GoQwerty or GoAzerty.

I put that code in my playerController.

t's quite easy to understand and that's the basic to key bind with unrealscript.
Careful when ever you change those key bind it's save in the config file.

No comments:

Post a Comment