73 lines
1.7 KiB
Lua
73 lines
1.7 KiB
Lua
local Ex05_BindInputs = UnLua.Class()
|
|||
|
|
function Ex05_BindInputs.ReceiveBeginPlay(self)
|
||
|
|
self.Overridden.ReceiveBeginPlay(self)
|
||
|
|
self.lastAction = ""
|
||
|
|
self.moveForwardValue = 0
|
||
|
|
self.enhancedCount = 0
|
||
|
|
end
|
||
|
|
function Ex05_BindInputs.HandleSpacePressed(self)
|
||
|
|
self.lastAction = "SpaceBar:Pressed"
|
||
|
|
end
|
||
|
|
function Ex05_BindInputs.HandleCtrlSave(self)
|
||
|
|
self.lastAction = "Ctrl+S"
|
||
|
|
end
|
||
|
|
function Ex05_BindInputs.HandleJumpAction(self)
|
||
|
|
self.lastAction = "Action:Jump"
|
||
|
|
end
|
||
|
|
function Ex05_BindInputs.HandleMoveForward(self, axisValue)
|
||
|
|
self.moveForwardValue = axisValue
|
||
|
|
end
|
||
|
|
function Ex05_BindInputs.HandleEnhancedMove(self, actionValue)
|
||
|
|
self.enhancedCount = self.enhancedCount + 1
|
||
|
|
self.moveForwardValue = actionValue
|
||
|
|
end
|
||
|
|
function Ex05_BindInputs.GetLastAction(self)
|
||
|
|
return self.lastAction
|
||
|
|
end
|
||
|
|
function Ex05_BindInputs.GetMoveForwardValue(self)
|
||
|
|
return self.moveForwardValue
|
||
|
|
end
|
||
|
|
function Ex05_BindInputs.GetEnhancedCount(self)
|
||
|
|
return self.enhancedCount
|
||
|
|
end
|
||
|
|
UnLua.Input.BindKey(
|
||
|
|
Ex05_BindInputs,
|
||
|
|
"SpaceBar",
|
||
|
|
"Pressed",
|
||
|
|
function(self)
|
||
|
|
self:HandleSpacePressed()
|
||
|
|
end
|
||
|
|
)
|
||
|
|
UnLua.Input.BindKey(
|
||
|
|
Ex05_BindInputs,
|
||
|
|
"S",
|
||
|
|
"Pressed",
|
||
|
|
function(self)
|
||
|
|
self:HandleCtrlSave()
|
||
|
|
end,
|
||
|
|
{Ctrl = true}
|
||
|
|
)
|
||
|
|
UnLua.Input.BindAction(
|
||
|
|
Ex05_BindInputs,
|
||
|
|
"Jump",
|
||
|
|
"Pressed",
|
||
|
|
function(self)
|
||
|
|
self:HandleJumpAction()
|
||
|
|
end
|
||
|
|
)
|
||
|
|
UnLua.Input.BindAxis(
|
||
|
|
Ex05_BindInputs,
|
||
|
|
"MoveForward",
|
||
|
|
function(self, axisValue)
|
||
|
|
self:HandleMoveForward(axisValue)
|
||
|
|
end
|
||
|
|
)
|
||
|
|
UnLua.EnhancedInput.BindAction(
|
||
|
|
Ex05_BindInputs,
|
||
|
|
"/Game/Input/IA_Move.IA_Move",
|
||
|
|
"Triggered",
|
||
|
|
function(self, actionValue)
|
||
|
|
self:HandleEnhancedMove(actionValue)
|
||
|
|
end
|
||
|
|
)
|
||
|
|
return Ex05_BindInputs
|