domingo, 28 de enero de 2024

Instanciar en Godot solo me funciona en la version 3 de godot no en la 4.2;

 extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



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

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





func _on_Timer_timeout():

spawn_ProjCopies()

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

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

EXPLICACION : SI QUIERES INSTANCIAR OBJETOS DENTRO DE UNA ESCENA USA LA VERSION 3 DE GODOT DONDE TIENE EL NODO SPATIAL LA VERSION 4.2 LLEVO SEMANAS INTENTANDOLO Y NO ENCUENTRO NI EJEMPLOS POR INTERNET....

aqui facilito un video del tema es una practica que hice de otro que vi en internet y con paciencia logre el mismo resultado.........mi fallo usaba la version de godot4,2 y este video solo funciona si se usa godot3 en la version 3 recalco version 3.5.3 estable


extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



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

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





#func _on_Timer_timeout():

#spawn_ProjCopies()


func _input(event):

if event is InputEventMouseButton:

if event.button_index == BUTTON_LEFT:

spawn_ProjCopies()



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

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

EXPLICACION: AQUI FUNCIONA PRESIONANDO BOTON IZQUIERDO DEL MOUSE

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







extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



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

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





#func _on_Timer_timeout():

#spawn_ProjCopies()


func _input(event):

if event is InputEventKey:

if event.scancode == KEY_A:

spawn_ProjCopies()




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

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

EXPLICACION: AQUI FUNCIONA PRESIONANDO LETRA "A" DEL TECLADO

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