//Here's 2.1 Knuckles physics!

addHook("ThinkFrame", do
	for player in players.iterate
        if player.mo == nil then continue end
        if player.mo.skin ~= "2.1knuckles" then
            continue
        end
		if ((player.mo.state == S_PLAY_GLIDE) or (player.pflags & PF_GLIDING)) and not P_IsObjectOnGround(player.mo)
			if (player.powers[pw_super])
				P_InstaThrust(player.mo, player.mo.angle, FixedMul(42*FRACUNIT, player.mo.scale))
			elseif (player.powers[pw_super]) and (player.mo.eflags & MFE_UNDERWATER)
				P_InstaThrust(player.mo, player.mo.angle, FixedMul(28*FRACUNIT, player.mo.scale))
			elseif (player.mo.eflags & MFE_UNDERWATER)
				P_InstaThrust(player.mo, player.mo.angle, FixedMul(14*FRACUNIT, player.mo.scale))
			else
				P_InstaThrust(player.mo, player.mo.angle, FixedMul(26*FRACUNIT, player.mo.scale))
			end
		end
		if (player.mo.state == S_PLAY_GLIDE_LANDING)
			S_StopSound(player.mo)
			P_ResetPlayer(player)
			S_StopSound(player.mo)
			player.mo.state = S_PLAY_WALK
		end
     if ((player.mo.state == S_PLAY_GLIDE) or (player.pflags & PF_GLIDING)) and leveltime % TICRATE == 1
     P_Thrust(player.mo, player.mo.angle, 1*FRACUNIT)
     end
     if ((player.mo.state == S_PLAY_GLIDE) or (player.pflags & PF_GLIDING))
			if (player.cmd.sidemove < 0)
				P_Thrust(player.mo, player.mo.angle+ANGLE_90, 2*FRACUNIT)
			elseif (player.cmd.sidemove > 0)
				P_Thrust(player.mo, player.mo.angle+ANGLE_90, -2*FRACUNIT)
		  end
     end
	end
end)