Weird jump issue with custom character controller

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)
1 Like

I suspect that since you are running the function OnUpdate every frame the character may get boosted higher than it is intended too. Why not try making the player jump when they press input rather than through frame changes?

You can also try turning Humanoid.UseJumpPower off, setting the Humanoid.JumpHeight to the value you want, and then calling Humanoid:ChangeState(Enum.HumanoidStateType.Jumping). However, I imagine the first reason is likely the cause.