-- Requests the mob to perform a jump if there's an obstacle in the way of it.

function AI:RequestJump(Mob)
	if not Mob.Instance then
		return
	end
	
	local Root: BasePart = Mob.Root
	local JumpHeight: number = (Mob.Enemy.JumpPower ^ 2) / (2 * workspace.Gravity) * .8
	local HipPoint: CFrame = Root.CFrame + (Root.CFrame.LookVector*(Root.Size.Z/2-0.2)) + (Root.CFrame.UpVector/-Root.Size.Y/2)
	
	local RaycastResult = workspace:Raycast(
		HipPoint.Position,
		HipPoint.LookVector * Mob.Enemy.WalkSpeed/4,
		RaycastParams
	)
	
	if RaycastResult then
		-- There is an obstacle, but they should be able to jump over it!
		if RaycastResult.Instance ~= workspace.Terrain then
			local PartHeight: number = (RaycastResult.Instance.Position + Vector3.new(0, RaycastResult.Instance.Size.Y/2, 0)).Y
			if (HipPoint.Position.Y + JumpHeight) > PartHeight then
				Mob.Enemy.Jump = true
			end
		else
			Mob.Enemy.Jump = true
		end
	end
end
