![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | hermo |
Hello! My 2d platformer game is structured like this:
Level03:
- tilemap
- player
- enemys
–enemy01
The problem is that the player’s script needs to access the tilemap and other nodes.
If I do get_node(‘/root/level03/tilemap’) it works but then the next level04 won’t work.
If I do get_parent().get_child(0) it also works but then I have to remember to keep the same structure all across the levels.
I thought in something like store a variable CURRENT_LEVEL=00 and increase it and then just get_node(level_CURRENT_LEVEL /tilemap) would be perfect but I can’t make it work
Is there any other way to do it?
Thank you!
just my idea not sure work or not but
var map_lvl = 1
var node ="level" + map_lvl
get_parent().get_node(node)
potatobanana | 2020-02-13 06:34