miércoles, 9 de abril de 2025

Godot 4.4 instancia la caida de dos piedras, dos GDScript, en el segundo GDScript hay un intervalo de 3 segundos de una piedra en otra;

 extends Area3D

#var Esferauno = preload("res://PERSONAJES MACABROS/ARAÑA/EXPLOTADA ARAÑA.tscn")

var Esferauno = preload("res://CONSTRUCCIONES/rigid_body_3d_piedra_cae-2-.tscn")

var EsferaDOS = preload("res://CONSTRUCCIONES/rigid_body_3d_piedra_cae-3-.tscn")

# Called when the node enters the scene tree for the first time.

func _ready() -> void:

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta: float) -> void:

#translate(Vector3(0,0,-0.001))

pass



func _on_area_entered(area: Area3D) -> void:


var parent = get_parent()


var CollisionShape3Dcubo = parent.get_node("CollisionShape3D")


get_node("CollisionShape3D").queue_free()

$"../RigidBody3D PIEDRA CAE".queue_free()


pass # Replace with function body.




func _on_area_exited(area: Area3D) -> void:


var Esferauno = Esferauno.instantiate()


add_child(Esferauno)


var EsferaDOS = EsferaDOS.instantiate()


add_child(EsferaDOS)


pass # Replace with function body.

-----------------------------------------------------------------------------------------------------------------------
ejemplo 2ª retrasa una piedra al caer 3 segundos
------------------------------------------------------------------------------------------------------------------
extends Area3D
#var Esferauno = preload("res://PERSONAJES MACABROS/ARAÑA/EXPLOTADA ARAÑA.tscn")
var Esferauno = preload("res://CONSTRUCCIONES/rigid_body_3d_piedra_cae-2-.tscn")
var EsferaDOS = preload("res://CONSTRUCCIONES/rigid_body_3d_piedra_cae-3-.tscn")

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
#translate(Vector3(0,0,-0.001))
pass


func _on_area_entered(area: Area3D) -> void:


var parent = get_parent()

var CollisionShape3Dcubo = parent.get_node("CollisionShape3D")

get_node("CollisionShape3D").queue_free()
$"../RigidBody3D PIEDRA CAE".queue_free()


pass # Replace with function body.



func _on_area_exited(area: Area3D) -> void:


var esfera_uno_instancia = Esferauno.instantiate()
add_child(esfera_uno_instancia)

# Llamar a una función para instanciar la segunda esfera después de un retraso
call_deferred("_instanciar_esfera_dos")

pass # Replace with function body.

func _instanciar_esfera_dos():
await get_tree().create_timer(3.0).timeout
var esfera_dos_instancia = EsferaDOS.instantiate()
add_child(esfera_dos_instancia)

No hay comentarios:

Publicar un comentario