![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | MisterMano |
I’m trying to spawn a NinePatch to serve as a text box. However, since it’s a child of the Player node, it uses the player’s origin as its own. So, as soon as it’s added as a child, it
var talkbox = load("res://objects/talkbox.tscn") #This scene is the 9patch with its own script.
var ibox = talkbox.instance()
#=== I have tried all of the options below, each by itself at a different time
ibox.rect_position = $playercamera.get_camera_screen_center()
ibox.rect_position = $playercamera.get_camera_position
ibox.rect_position = Vector2(position.x - 180, position.y + 100)
#===
$menuzindex.add_child(ibox)
The problem is that they always spawn the box in a different place compared to the center of the screen.
Is there a way to make a spawned node position itself relative to the visible screen? A gdscript function you can call?
I messed around with the 9patch anchor, but I couldn’t for the life of me get it to spawn where I need it to.