I have managed to instantiate the object now I’m trying to get the camera to that object but I have problems:
my code: for instantiation:
extends Node
func _ready():
for n in container.size():
dictCon[container[n].entityNum] = container[n]
initialize = true
var dictCon = {}
var initialize = false
@export var container: Array[Entity]
func CreateMe(index: int):
if not initialize:
await get_tree().process_frame
if(dictCon.has(index)):
var res = dictCon[index]
if res.scene == null:
printerr(String("index: [{i}] selected Entity: [{e}] does not have a scene\n{stack}").format({i = index, e = res.entityString, stack = get_stack()}))
else:
return res.scene.instantiate()
else:
printerr(String("wrong index: [{i}] selected Entity does not exist\n{stack}").format({i = index, stack = get_stack()}))
where I call the instantiation:
func _ready():
GameManager.planetPosition = position
GameManager.planet = transform
print("planet ready")
await get_tree().process_frame
print("planet ready 2")
#var item = await DataBaseResources.CreateMe(1)
#GameManager.map.add_child(item)
var c = await MP.CreateMe(2)
GameManager.map.add_child(c)
GameManager.camera.add_child(c)
print("BEFORE")
var s = c.get_script()
s.SetCamera()
When you run the game, in the scene tree where all the nodes in the editor, you will see two options, “remote” and “local”, so there, press the “remote” and see what happened, is the camera inside the game?