Godot, scripts para Godot estudios y aprendizajes, Creacion de videojuegos. Creacion y publicacion de videojuegos en internet. Como hacer videojuegos. C# unity. Animaciones unity blender. Personajes videojuegos graficos dibujos. Diseño grafico. Comic. Animaciones gif. Dibujo de retratos. Realidad virtual. Cine y realidad virtual.
viernes, 30 de mayo de 2025
Videojuego 3d con visiones y planos de 360 grados con la camara, en desarrollo , pronto a la venta en itch.io a finales de junio principios de julio del 2025;
martes, 27 de mayo de 2025
Uso de un func _on_body_entered(body: Node3D) -> void: para borrar un proyectil cuando colisiona;
extends Area3D
var score = 0
var speed = 15 # Unidades por segundo
var speed2 = 1 # Unidades por segundo
var tiempo_transcurrido = 0.0 # Tiempo en segundos
func _ready() -> void:
# Conecta la señal 'body_entered' a una función que manejará la colisión
body_entered.connect(_on_body_entered)
func _process(delta: float) -> void:
var movimiento = Vector3(0, speed2 * delta, speed * delta)
translate(movimiento)
tiempo_transcurrido += delta
if tiempo_transcurrido >= 10.0:
queue_free()
# Esta función se llamará cuando un cuerpo entre en esta área
func _on_body_entered(body: Node3D) -> void:
print("¡Colisión detectada con: ", body.name, "!")
queue_free() # Borra el nodo cuando colisiona
domingo, 18 de mayo de 2025
GDScript simplemente anima;
extends AnimationPlayer
func _ready() -> void:
$".".play("alas")
pass
func _process(delta: float) -> void:
pass
GDScript anima al presionar espacio;
extends AnimationPlayer
func _ready() -> void:
pass
func _process(delta: float) -> void:
if Input.is_action_just_pressed("ui_accept"):
play("alas")
GDScript anima al presionar espacio al soltar no anima;
extends AnimationPlayer
func _ready() -> void:
pass
func _process(delta: float) -> void:
if Input.is_action_pressed("ui_accept"):
if not is_playing():
play("alas")
else:
stop()
UN PERSONAJE CON MOVIMIENTO POR ESCENARIO ANIMACIONES PERSONALIZADAS ECHAS MANUALMENTE Y UNA CAMARA QUE ABARCA ABSOLUTAMENTE TODO EL ESCENARIO MIENTRAS JUGAMOS
----------------------------------------------------------------------------------------------------------------------------
EXPLICACION: Fantastico GDScript que mueve un MeshInstance3D que hace como de grua de una camara , la camara es el hijo, a su vez el MeshInstance3D es hijo de un CharacterBody3D.
El CharacterBody3D tiene su propio GDScript para mover al personaje, y la camara hace una vision de todo el escenario de 360 grados que no se separa del player, puedes mover a tu personaje y darle los movimientos que desees, y a la vez ver todo lo que hay a tu alrrededor moviendo el mouse arrastrandolo de adelante hacia atras y de izquierda a derecha, para completar esta explicacion pongo tambien el GDScript que lleva el Player protagonista de la escena......
---------------------------------------------------------------------------------------------------------------------
extends MeshInstance3D
var rotate_speed_drag_y = 5.44# Sensibilidad de la rotación en Y
var rotate_speed_drag_x = 5.44 # Sensibilidad de la rotación en X
var smoothing_factor = 0.01 # Factor de suavizado (0.0 - 1.0, valores más bajos = más suavizado)
var target_rotation = Vector3()
var last_mouse_position = Vector2()
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
target_rotation = rotation_degrees # Inicializa la rotación objetivo con la actual
func _process(delta):
var current_mouse_position = get_viewport().get_mouse_position()
var delta_x = current_mouse_position.x - last_mouse_position.x
var delta_y = current_mouse_position.y - last_mouse_position.y
target_rotation.y -= delta_x * rotate_speed_drag_y * 90 * delta # Ajusta la rotación objetivo en Y
target_rotation.x -= delta_y * rotate_speed_drag_x * 90 * delta # Ajusta la rotación objetivo en X
# Aplica el suavizado a la rotación actual
rotation_degrees = lerp(rotation_degrees, target_rotation, smoothing_factor)
last_mouse_position = current_mouse_position
func _input(event):
if event is InputEventMouseMotion:
last_mouse_position = event.position
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
EXPLICACION: Este GDScript se pone al nodo del personaje es exclusivo de su animacion de movimientos del esqueleto presionando las teclas y botones del mouse..el nodo es hijo del CharacterBody3D.
--------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
extends Node3D
var animacion_actual = "MakeHuman default skeleton|REPOSA"
func _ready():
$AnimationPlayer.play(animacion_actual)
func _physics_process(delta):
var alguna_tecla_pulsada = false
# Comprobamos si alguna de las acciones está siendo presionada
if Input.is_action_pressed("achazo") or \
Input.is_action_pressed("mouse_left") or \
Input.is_action_pressed("mouse_right") or \
Input.is_action_pressed("RETUERCE") or \
Input.is_action_pressed("ANDAALANTECONW") or \
Input.is_action_pressed("A") or \
Input.is_action_pressed("D"):
alguna_tecla_pulsada = true
# Animación de ESPADAZO
if Input.is_action_pressed("achazo") or Input.is_action_pressed("mouse_left"):
if animacion_actual != "MakeHuman default skeleton|ATACA":
$AnimationPlayer.play("MakeHuman default skeleton|ATACA")
#$AnimationPlayer/AudioStreamPlayer3D.play("MakeHuman default skeleton|ESPADAZO")
animacion_actual = "MakeHuman default skeleton|ATACA"
# Animación de ATRABESAR
elif Input.is_action_pressed("mouse_right") or Input.is_action_pressed("RETUERCE"):
if animacion_actual != "MakeHuman default skeleton|ATACA":
$AnimationPlayer.play("MakeHuman default skeleton|ATACA")
animacion_actual = "MakeHuman default skeleton|ATACA"
# Animación de ANDAR
elif Input.is_action_pressed("ANDAALANTECONW") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):
if animacion_actual != "MakeHuman default skeleton|ANDA50":
$AnimationPlayer.play("MakeHuman default skeleton|ANDA50")
animacion_actual = "MakeHuman default skeleton|ANDA50"
# Si no se presiona ninguna tecla, volvemos a la animación de descanso
elif not alguna_tecla_pulsada:
if animacion_actual != "MakeHuman default skeleton|REPOSA":
$AnimationPlayer.play("MakeHuman default skeleton|REPOSA")
animacion_actual = "MakeHuman default skeleton|REPOSA"
--------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
EXPLICACION: GDScript exclusivo para trasladar y hacer saltar al CharacterBody3D padre de los elementos de los 2 anteriores GDScript
-------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
extends CharacterBody3D
var rotate_speed = 0.1 # Rotation speed
const SPEED = 0.02 # Movement speed
const JUMP_VELOCITY = 0.5 # Jump velocity
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _ready():
# Replace with function body
pass
func _physics_process(delta):
#translate(Vector3(0,0,-0.01))# PARA UNA CONSTANCIA DE MOVIMIENTO CONTINUO
if not is_on_floor():
velocity.y -= gravity * delta # Apply gravity
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY # Jump
#var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") # Get input direction
var input_dir = Input.get_vector("GIRAIZQUIERDACONA", "GIRADERECHACOND", "ANDAALANTECONW", "ANDAATRASCONS") #ESTE FUNCIONABA ESTE FUNCIONABA
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED # Move in X direction
velocity.z = direction.z * SPEED # Move in Z direction
else:
velocity.x = move_toward(velocity.x, 0, SPEED) # Stop horizontal movement
velocity.z = move_toward(velocity.z, 0, SPEED) # Stop vertical movement
move_and_slide() # Apply movement and collisions
var movimiento_vector = Vector3.ZERO # Initialize movement vector
#if Input.is_action_pressed("A"): # Move forward
#rotate_x(0.01) # Rotate on X axis (negative for down)
#if Input.is_action_pressed("D"): # Move forward
#rotate_x(0.01) # Rotate on X axis (negative for down)
if Input.is_action_pressed("giraz"):
rotate_x(0.05) # Rotate on Z axis (positive for left)
if Input.is_action_pressed("girax"):
rotate_x(-0.05) # Rotate on Z axis (positive for left)
#elif Input.is_action_pressed("B"): # Move backward
#rotate_x(-0.01) # Rotate on X axis (positive for up)
if Input.is_action_pressed("GIRAIZQUIERDACONA"):
rotate_y(0.05) # Rotate on Z axis (positive for left)
if Input.is_action_pressed("GIRADERECHACOND"):
rotate_y(-0.05) # Rotate on Z axis (negative for right)
#translate(Vector3(0.05,0,0))
if Input.is_action_pressed("ANDAALANTECONW"):
translate(Vector3(0.00,0,0.0004))
rotate_y(-0.00)
if Input.is_action_pressed("ANDAATRASCONS"):
translate(Vector3(0.00,0,-0.0004))
rotate_y(-0.00)
# Rotación vertical con la rueda del ratón
if Input.is_action_pressed("rodarriba"):
print("rodarriba activado") # Añadido para depurar
rotate_x(-rotate_speed)
if Input.is_action_pressed("rodavajo"):
print("rodavajo activado") # Añadido para depurar
rotate_x(rotate_speed)
--------------------------------------------------------
---------------------------------------------------------
--------------------------------------------------------
-----------------------------------------------------------
RESUMEN: -1-UN CharacterBody3D CON SU PROPIO GDSCRIPT PADRE.
-2- UN NODO CON EL PLAYER CON SU PROPIO GDSCRIPT HIJO.
-3-UN MeshInstance3D QUE CONTIENE LA CAMARA CON SU PROPIO
GDSCRIPT HIJO.
RESULTADO TENEMOS UN PERSONAJE CON MOVIMIENTO POR ESCENARIO ANIMACIONES PERSONALIZADAS ECHAS MANUALMENTE Y UNA CAMARA QUE ABARCA ABSOLUTAMENTE TODO EL ESCENARIO MIENTRAS JUGAMOS