-- name: Eje Invertido y Vuelo Libre
-- description: Mod estricto de vuelo libre con eje Y normalizado (Arriba=Subir). Requiere triple salto.
local FLIGHT_SPEED = 32.0 -- Velocidad constante hacia adelante al volar
local VERTICAL_SPEED = 20.0 -- Velocidad de subida y bajada en el aire
local isCustomFlying = false
hook_event(HOOK_BEFORE_PHYS_STEP, function(m)
if m.playerIndex ~= 0 then return end
-- Activar el vuelo personalizado estrictamente tras el triple salto nativo o cañón
if m.action == ACT_FLYING and not isCustomFlying then
isCustomFlying = true
end
-- Cancelar el vuelo si ocurre una colisión con el suelo, daño o si entra al agua
if (m.action & ACT_FLAG_STATIONARY) ~= 0 or (m.action & ACT_FLAG_ON_GROUND) ~= 0 or
m.action == ACT_SQUISHED or m.action == ACT_BACKWARD_AIR_KB or (m.action & ACT_FLAG_SWIMMING) ~= 0 then
isCustomFlying = false
end
-------------------------------------------------------------------------
-- VUELO LIBRE (Arriba = Subir / Abajo = Bajar)
-------------------------------------------------------------------------
if isCustomFlying then
m.action = ACT_FLYING
m.peakHeight = m.pos.y -- Evita daño por caída al aterrizar
-- Giro horizontal hacia donde apunte el joystick
if m.intendedMag > 0 then
m.faceAngle.yaw = m.intendedYaw
end
-- Avanzar siempre hacia el frente de forma constante
m.forwardVel = FLIGHT_SPEED
-- EJE Y MODIFICADO: Palanca ARRIBA (stickY positivo) SUBE / Palanca ABAJO BAJA
if m.controller.stickY ~= 0 then
local stickYNormalized = m.controller.stickY / 64.0
m.pos.y = m.pos.y + (stickYNormalized * VERTICAL_SPEED)
-- Inclinar visualmente el cuerpo de Mario hacia arriba o abajo según la palanca
m.faceAngle.pitch = math.floor(-stickYNormalized * 0x1A00)
else
m.faceAngle.pitch = 0
end
-- Forzar la animación de vuelo estable para eliminar los balanceos nativos
set_mario_animation(m, MARIO_ANIM_WING_CAP_FLY)
return true -- Cancelar las físicas nativas de planeo para garantizar el control directo
end
end)
To embed this project on your website, copy the following code and paste it into your website's HTML: