I’m currently learning about ECS which is a type of design pattern for anyone who doesn’t know and I’ve been trying to do input with it and I’ve gotten it to work the only issue is it doesn’t have anyway to check for GameProcessed. During my research I’ve learned you don’t need to use ECS for everything so perhaps the solution is to just do my input normally, but wanna try this way first at least. Anyone with more experience using ECS and Matter perhaps you could give me some tips?
local Matter = require(RepStorage:WaitForChild("Packages").Matter)
local function InputSystem(world)
for id, input, keybinds in world:query(Components.Input, Components.Keybinds) do
local moveForwardKeyDown = UIS:IsKeyDown(keybinds.Keys["MoveForward"])
local moveBackwardKeyDown = UIS:IsKeyDown(keybinds.Keys["MoveBackward"])
local moveLeftKeyDown = UIS:IsKeyDown(keybinds.Keys["MoveLeft"])
local moveRightKeyDown = UIS:IsKeyDown(keybinds.Keys["MoveRight"])
world:insert(id, input:patch({
ForwardValue = moveForwardKeyDown and -1 or 0,
BackwardValue = moveBackwardKeyDown and 1 or 0,
LeftValue = moveLeftKeyDown and -1 or 0,
RightValue = moveRightKeyDown and 1 or 0
}))
end
end
return InputSystem