martes, 24 de junio de 2025

Dos formas de instanciar disparos con Godot 4.4 con el boton izquierdo del raton;

 extends Area3D


var Bullet = preload("res://PROTAGONISTA/area_3dPROLLECTIL.tscn")


func _input(event):

if event is InputEventMouseButton:

if event.button_index == 1 and event.pressed:

# Retrasar la instanciación del proyectil

await get_tree().create_timer(0.5).timeout

var bullet = Bullet.instantiate()

add_child(bullet)

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

Explicacion : retrasa el disparo 0.5 segundos DESPUES de pulsar el boton del mouse.

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

extends Area3D


var Bullet = preload("res://PROTAGONISTA/area_3dPROLLECTIL.tscn")

var can_fire = true


func _input(event):

if event is InputEventMouseButton:

if event.button_index == 1 and event.pressed:

if can_fire:

can_fire = false

var bullet = Bullet.instantiate()

add_child(bullet)

await get_tree().create_timer(0.5).timeout

can_fire = true


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

Explicacion : retrasa el disparo 0.5 segundos ENTRE DISPARO Y DISPARO al pulsar boton del mouse.

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

No hay comentarios:

Publicar un comentario