Instance more then once

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Drawsi

I keep having this problem where it doesn’t instance my scene more then once which is really annoying me

extends Area2D

#Coordonates and position
var cell_size = 1

var x = get_global_mouse_position().x
var y = get_global_mouse_position().y
export var cube_thing = preload("res://Scene.tscn")
var Scene = cube_thing.instance()

#Hidden mouse
func _ready(): 
	set_process_input(true)
	Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
	$Sprite.position = get_global_mouse_position()

#Actual movement
func _input(event):
	if event is InputEventMouseButton:
		self.add_child(Scene)
:bust_in_silhouette: Reply From: deaton64

Hi,
You’re instancing the same scene in the same place.
If you want to do that, then set the position before you instance it.
If you want more than one instance, move the instance() call:

func _input(event):
	if event is InputEventMouseButton:
		var Scene = cube_thing.instance()
		Scene.position = get_global_mouse_position()
		self.add_child(Scene)

Thank you so much!!
You just solved something I had problem with for weeks and had no idea how to approach!!

Drawsi | 2020-06-19 19:52