Sprite in sprite or scene deep inside scene

Godot Version

4.2.2 stable

Question

I’m a week old GoDot programmer so I’m probably going in wrong direction would need you guys to correct me thanks in advance

I’m trying to make as I manage to did it at the moment.
but this is static not dynamic

I would have to add for each sprite new copy paste sprite and link it to the code

I know first thing is to make a scene from sprite I’ve made
that’s SpriteHead

this is what it looks like

I’ve tried to make a scene of a sprite BUT I’ve hit a wall

like I can’t put sprite inside sprite

not first node

but inside SprieContainer

Like this:

SpriteHead is full sprite that I want to populate as much as I want inside SpriteContainer and inside those sprites if it has a spriteHead in their SpriteContainer

Like this:

and oh no it didn’t go little bit to the right as the middle 2 ones went (2, 3)

so if we sum up the problems:

  • how to populate scene deep inside scene
  • how to move offset of a sprite a little bit to the right

I want make it look like this:

-SpriteHead1
__-SpriteHead2
__-SpriteHead3
____-SpriteHead4

and if you turn off 1 you don’t see 2, 3, 4
if you turn off 3 you don’t see 4

if you find solution how else to do this I’d like to hear

thanks in advance

use margin container, set the margin left to some px

ok I tried probably in wrong way

now it went as it should but when I set SpriteHead3 in that it went left instead of right

put the “container” of SpriteHead3 inside “MarginContainer” you just created
if you also want the “sprite” also got shifted to the right, then you will need to add another hboxcontainer inside margincontainer
but i think you can ignore all of these above and just actually put Hboxcontainer inside the SpriteHead3 and add v separator node the very first child of it, then followed with “sprite” and “container”
there are many ways to do this. the other way is to actually use Control node after the SpriteHead3 and everything inside it will get to use some size without being locked by the container

1 Like

gr8 works perfectly

now last question from this topic

how do I make a scene out of SpriteHead (I know how) but how to give another SpriteHead inside SpriteHead-SpriteContainer

after you created a scene, instantiate it directly to the main gui scene, then right click it and check the editable child option. this should show you the “container” node of the scene you created and let you put another scene inside it

above is done via editor. if you meant to do it via code, then the first thing you need to do is to have the SpriteHead Scene’s script to have reference variable to the “container” node. so when you need to instantiate+add_child another scene to it, just sprite_head.the_container.add_child(another_sprite_head)

1 Like

thanks this is much easier than in Unity 3D

I had to code allot to do this what I did with few clicks

1 Like