miércoles, 24 de septiembre de 2025

Lanzar piedras gdscript godot 4.4; 3d;

 extends CharacterBody3D


var rotate_speed = 10.1

const SPEED = 99.09

const JUMP_VELOCITY = 22.3

var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")

@export var FORWARD_JUMP_AMOUNT = -4.7


# --- NUEVAS VARIABLES PARA LANZAR LA PIEDRA ---

# ¡IMPORTANTE! Cambia esta ruta por la de tu escena de la piedra

var stone_scene = preload("res://PROTAGONISTA/BONBADEMANO.tscn")

@export var throw_strength: float = 15.0 


# --- NUEVA VARIABLE para la rotación con las teclas Z y X ---

var player_mesh: MeshInstance3D


func _ready():

# --- OBTENER REFERENCIA al nodo MeshInstance3D ---

# Asegúrate de que "MeshInstance3D" es el nombre exacto de tu nodo 3D.

player_mesh = get_node("MeshInstance3D")


# --- NUEVA FUNCIÓN para detectar el clic del ratón ---

func _unhandled_input(event):

if event.is_action_pressed("mouse_left"):

throw_stone()


func _physics_process(delta):

# Aplicar gravedad

if not is_on_floor():

velocity.y -= gravity * delta


# Movimiento de Salto

if Input.is_action_just_pressed("ui_accept") and is_on_floor():

velocity.y = JUMP_VELOCITY

velocity += -transform.basis.z * FORWARD_JUMP_AMOUNT


# --- LÓGICA de rotación para la tecla 'Z' y 'X' (ahora afecta al mesh) ---

if Input.is_key_pressed(KEY_Z):

if player_mesh:

player_mesh.rotate_object_local(Vector3.FORWARD, 1.0 * delta)

if Input.is_key_pressed(KEY_X):

if player_mesh:

player_mesh.rotate_object_local(Vector3.FORWARD, -1.0 * delta)


# --- Tu lógica de movimiento y rotación original ---

if Input.is_action_pressed("GIRAIZQUIERDACONA"):

rotate_y(0.05)

if Input.is_action_pressed("GIRADERECHACOND"):

rotate_y(-0.05)

if Input.is_action_pressed("ANDAALANTECONW"):

translate(Vector3(0.0,0,0.11))

rotate_y(-0.00)

if Input.is_action_pressed("E"):

translate(Vector3(0.01,0,0.22))

rotate_y(-0.00)

if Input.is_action_pressed("ANDAATRASCONS"):

translate(Vector3(0.00,0,-0.02))

rotate_y(-0.00)

rotate_y(rotation_input.y * delta * rotate_speed)

rotate_x(rotation_input.x * delta * rotate_speed)

rotation_input = Vector2.ZERO


var input_dir = Input.get_vector("ui_right", "ui_left", "ui_down", "ui_up")

var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

if direction:

velocity.x = direction.x * SPEED

velocity.z = direction.z * SPEED

else:

velocity.x = move_toward(velocity.x, 0, SPEED)

velocity.z = move_toward(velocity.z, 0, SPEED)


move_and_slide()


var rotation_input: Vector2 = Vector2.ZERO


# --- FUNCIÓN para lanzar la piedra ---

func throw_stone():

var stone_instance = stone_scene.instantiate()

# Posicionar la piedra en la misma posición y rotación que el jugador

stone_instance.global_transform = global_transform

# Obtener la dirección "hacia adelante" del jugador

var direction = global_transform.basis.z

# Aplicar una fuerza inicial para lanzarla

stone_instance.apply_central_impulse(direction * throw_strength)

# Añadir la piedra a la escena principal

get_parent().add_child(stone_instance)

jueves, 11 de septiembre de 2025

Animar personaje en godot 4.4. "RELAJO""CAMINA""BOMBAMANO""CORRECACA";


 extends Node3D


var animacion_actual = "RELAJO"


func _ready():

$AnimationPlayer.play(animacion_actual)


func _physics_process(delta):


# NUEVO CÓDIGO: Salir del juego al presionar la tecla Escape

if Input.is_action_just_pressed("ui_cancel"):

get_tree().quit()

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("DESDEABAJOPUÑETASO") or \

   Input.is_action_pressed("ANDAALANTECONW") or \

   Input.is_action_pressed("ANDAATRASCONS") or \

   Input.is_action_pressed("DESDEABAJOPUÑETASO") or \

   Input.is_action_pressed("DESDEABAJOPUÑETASO") or \

   Input.is_action_pressed("CORRECACA") or \

   Input.is_action_pressed("PATADAMEDIA") or \

   Input.is_action_pressed("DESDEABAJOPUÑETASO") or \

   Input.is_action_pressed("ui_accept") 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 != "BOMBAMANO":

$AnimationPlayer.play("BOMBAMANO")

#$AnimationPlayer/AudioStreamPlayer3D.play("MakeHuman default skeleton|ESPADAZO")

animacion_actual = "BOMBAMANO"


# Animación de ATRABESAR

elif Input.is_action_pressed("mouse_right") or Input.is_action_pressed("DESDEABAJOPUÑETASO"):

if animacion_actual != "BOMBAMANO":

$AnimationPlayer.play("BOMBAMANO")

animacion_actual = "BOMBAMANO"


# 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 != "CAMINA":

$AnimationPlayer.play("CAMINA")

animacion_actual = "CAMINA"

elif Input.is_action_pressed("ANDAATRASCONS") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):

if animacion_actual != "CAMINA":

$AnimationPlayer.play("CAMINA")

animacion_actual = "CAMINA"

elif Input.is_action_pressed("PUÑETAZO") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):

if animacion_actual != "CAMINA":

$AnimationPlayer.play("CAMINA")

animacion_actual = "CAMINA"

elif Input.is_action_pressed("CORRECACA") or Input.is_action_pressed("E") or Input.is_action_pressed("E"):

if animacion_actual != "CORRECACA":

$AnimationPlayer.play("CORRECACA")

animacion_actual = "CORRECACA"


elif Input.is_action_pressed("PATADAMEDIA") or Input.is_action_pressed("R") or Input.is_action_pressed("R"):

if animacion_actual != "BOMBAMANO":

$AnimationPlayer.play("BOMBAMANO")

animacion_actual = "BOMBAMANO"




elif Input.is_action_pressed("ui_accept") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):

if animacion_actual != "CAMINA":

$AnimationPlayer.play("CAMINA")

animacion_actual = "CAMINA"


elif Input.is_action_just_pressed("PUÑETAZO") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):

if animacion_actual != "CAMINA":

$AnimationPlayer.play("CAMINA")

animacion_actual = "CAMINA"



# Si no se presiona ninguna tecla, volvemos a la animación de descanso

elif not alguna_tecla_pulsada:

if animacion_actual != "RELAJO":

$AnimationPlayer.play("RELAJO")

animacion_actual = "RELAJO"

elif Input.is_action_pressed("achazo") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):

if animacion_actual != "CAMINA":

$AnimationPlayer.play("CAMINA")

animacion_actual = "CAMINA"

miércoles, 3 de septiembre de 2025

Me inspiro Medal of Honor.;

 




El video que compartiste es un interesante tutorial y gameplay de un juego que creaste, claramente inspirado en la saga de Medal of Honor [00:11].

En el video, explicas que tu juego es un tributo a la obra del director Steven Spielberg, el cual te inspiró para desarrollarlo [00:32].

El juego, que también tiene un final que funciona como homenaje a Medal of Honor, tiene como objetivo que el jugador, un soldado estadounidense, se infiltre en una base de bunkers alemanes y encuentre una medicina especial para ganar [01:41].

El video muestra un recorrido completo de la jugabilidad, incluyendo:

Cómo correr y disparar [03:31].

Que el juego puede reiniciarse al ser eliminado pulsando la tecla 'O' [02:34].

Cómo lanzar granadas con la tecla 'M' [04:23].

Al final, se puede ver la pantalla de "Misión cumplida" que aparece al completar el objetivo [09:56]. El video termina con unos créditos que, según comentas, son un tributo al juego original [10:45].