I’m making a 2D smash bros-esc fighting game, and so to make the controls feel more like a 2d game I made my own custom controller for the character. For some odd reason though, the character jumps way too high for what I intended, and also half the time the character just wont even jump.
GIF
Portion of code in action
local function onJump(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
jumping = true
elseif inputState == Enum.UserInputState.End then
jumping = false
end
end
local function onUpdate()
if Character and Character:FindFirstChild("Humanoid") then
if jumping then
if Humanoid:GetState() == Enum.HumanoidStateType.Jumping or Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if InAir == false then
return Enum.ContextActionResult.Sink
end
InAir = false
Character.HumanoidRootPart.Velocity = Vector3.new(0, Humanoid.JumpPower + 8, 0) + Character.HumanoidRootPart.Velocity;
Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Movements.DoubleJump):Play()
elseif Humanoid.FloorMaterial ~= Enum.Material.Air then
InAir = true
Character.HumanoidRootPart.Velocity = Vector3.new(0, Humanoid.JumpPower, 0) + Character.HumanoidRootPart.Velocity;
end
end
local moveDirection = rightValue - leftValue
Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
end
end
RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
ContextActionService:BindAction("Jump", onJump, true, "w", Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)