sábado, 15 de agosto de 2026

GDScript para camara 3d en Godot 4.7, se mueve con el mouse y al presionar escape sales del juego; y te trasladas adelante atras izquierda y derecha;con -w-s-a-d;

 extends Camera3D


# Parámetros ajustables desde el inspector

@export var speed: float = 5.0

@export var mouse_sensitivity: float = 0.003


var rotation_x: float = 0.0


func _ready() -> void:

# Oculta y atrapa el puntero del ratón

Input.mouse_mode = Input.MOUSE_MODE_CAPTURED


func _unhandled_input(event: InputEvent) -> void:

# 1. Salir del juego al pulsar la tecla Escape

if event.is_action_pressed("ui_cancel") or (event is InputEventKey and event.pressed and event.keycode == KEY_ESCAPE):

get_tree().quit()


# 2. Rotación de la cámara con el ratón

if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:

# Girar a los lados (Eje Y global para no inclinarnos de lado)

rotate_y(-event.relative.x * mouse_sensitivity)

# Mirar arriba y abajo (Eje X local con límite)

rotation_x -= event.relative.y * mouse_sensitivity

rotation_x = clamp(rotation_x, deg_to_rad(-89.0), deg_to_rad(89.0))

rotation.x = rotation_x


func _process(delta: float) -> void:

# 3. Detectar teclas WASD para calcular la dirección de movimiento

var input_dir := Vector3.ZERO


if Input.is_key_pressed(KEY_W):

input_dir.z -= 1  # Adelante

if Input.is_key_pressed(KEY_S):

input_dir.z += 1  # Atrás

if Input.is_key_pressed(KEY_A):

input_dir.x -= 1  # Izquierda

if Input.is_key_pressed(KEY_D):

input_dir.x += 1  # Derecha


# Normalizar para que la velocidad no se duplique al moverte en diagonal

if input_dir != Vector3.ZERO:

input_dir = input_dir.normalized()


# 4. Mover la cámara según la dirección hacia la que está mirando

var direction := (transform.basis * input_dir).normalized()

global_position += direction * speed * delta


----------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------

Explicacion: estupendo GDScript para manejar una camara3d en Godot 4.7, puedes explorar todo el entorno de un juego 3d con mucha facilidad:

GDScript para camara 3d en Godot 4.7, se mueve con el mouse y al presionar escape sales del juego;

 extends Camera3D


# Sensibilidad del ratón (ajusta este valor a tu gusto)

@export var mouse_sensitivity: float = 0.003


# Variables para controlar los límites de rotación vertical (mirar arriba/abajo)

var rotation_x: float = 0.0


func _ready() -> void:

# Captura y oculta el puntero del ratón en la pantalla

Input.mouse_mode = Input.MOUSE_MODE_CAPTURED


func _unhandled_input(event: InputEvent) -> void:

# 1. Salir del juego si se presiona la tecla Escape

if event.is_action_pressed("ui_cancel") or (event is InputEventKey and event.pressed and event.keycode == KEY_ESCAPE):

get_tree().quit()


# 2. Control de la cámara con el movimiento del ratón

if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:

# Giro horizontal (Eje Y)

rotate_y(-event.relative.x * mouse_sensitivity)

# Giro vertical (Eje X) con límite para no dar la vuelta completa

rotation_x -= event.relative.y * mouse_sensitivity

rotation_x = clamp(rotation_x, deg_to_rad(-89.0), deg_to_rad(89.0))

# Aplicamos la rotación vertical a la cámara

rotation.x = rotation_x

Un aficionado se da cuenta de los efectos de las censuras en el desarrollo de videojuegos indie; Itch.io, steam; baneados por procesadores de pago;

 

Comentarios

The wolfman is a superstar, you should continue the series or make a spirituals successor like the new adventures of MMMesaltmalomalal. You should also add sex, violence and a little bit of your sense of humor, like the lady in the pink suit with her panties down:)

(+1)

None of that can be done anymore, everything’s censored. It’s a disgrace, but they don’t even show it for free on itch.io anymore. It wouldn’t even appear on the lists. What’s the point of making games that nobody’s going to look at? And that they won’t let me sell?

(+1)

Follow me if you’d like at https://perico415.itch.io/. I’ll try to keep going with horror games if they don’t ban them too…

You are right sadly, but I like the fact that you didn't give up. Maybe new platforms will appear in time. Best of luck in your projects!