I’ve been trying to figure out how to make motion inputs for a fighting game although I just haven’t been able to figure it out in-fact I kind of don’t even fully know how it works I’ve tried doing some research and apparently there’s a thing called buffering which waits or queues inputs before doing them or at least I think that’s what it is. Anyways looking for some help on how I can make motion inputs.
It’s not much, but here’s what I’ve done
--| Services
local UIS = game:GetService("UserInputService")
--| Modules
local CharacterSpecific = require(script:WaitForChild("ModuleScript"))
--| Variables
local Inputs = {}
--These are the base controls. Every character access to punches and kicks.
local Controls = {
["B"] = function()
warn("Medium Kick")
end,
["N"] = function()
warn("Light Kick")
end,
["G"] = function()
warn("Light Punch")
end,
["H"] = function()
warn("Medium Punch")
end,
--Apparently doing this is better than table.find sooo ignore these they don't do anything
["W"] = function()
end,
["A"] = function()
end,
["S"] = function()
end,
["D"] = function()
end,
}
--[[
coroutine.wrap(function()
while wait() do
if #Inputs ~= 0 then
local Old = Inputs
wait(0.5)
if #Inputs == #Old then
Inputs = {}
warn("RESET")
end
end
end
end)()
]]
UIS.InputBegan:Connect(function(Input,IsTyping)
if IsTyping then return end
local Key = UIS:GetStringForKeyCode(Input.KeyCode)
if Controls[Key] then
table.insert(Inputs,Key) --insert the key pressed into the table
local String = table.concat(Inputs) --turn the table into a string (not sure if this is helpful I just have it here just in case)
warn(Inputs)
warn("PREVIOUS INPUT: "..Inputs[#Inputs-1])
warn("NEW INPUT: "..Inputs[#Inputs])
--[[
if CharacterSpecific.Moves[String] then
CharacterSpecific.Moves[String]()
elseif Controls[Key] then
Controls[Key]()
end
for Combo,_ in pairs(CharacterSpecific.Moves) do
if String:find(Combo) then
CharacterSpecific.Moves[Combo]()
Inputs = {}
end
end
]]
end
end)
local module = {}
--These are specific inputs unique to the character
module.Moves = {
["SG"] = function()
warn("Move 1")
end,
["ASDB"] = function()
warn("Move 2")
end,
["DSAG"] = function()
warn("Move 2")
end,
}
return module