#trying to pass a resource to a child and getting this error
1 messages · Page 1 of 1 (latest)
battle contains enemy_group which needs to duplicate enemy based on how many enemies are in the initial array
the child runs this on _ready()
If you're coming from other programming languages, for i in array is equivalent to a "for each" loop rather than a standard for.
i in this case is already a Resource, so you can either do instance.resource = i, or change the loop to for i in enemies.size().
No problem.
it kinda does
i think it's just the enemy not loading its texture
$Sprite2D.texture = TEXTURE
i have this
it doesnt load tho
wait i just forgot to specify it xd
thankyou
can the child see its own ID?
Which ID do you mean, sorry?
The position in the array, or the actual ID that Godot assigns each node?
the position in the array
No. The only ways to know are either to iterate using an integer so that you can use it again later, (i.e. save the i from for i in enemies.size()) or to search for it inside the array later (var i = enemies.find(enemy)). But if you do hold onto the original position in the array, that will get out of date if you ever delete anything from earlier in the array, so finding it when you need it is the safest way.
thats gonna be a bit tricky
i was going to have enemies attack in order of index
i guess i could have entities attack when a var reaches their ID, and it skips enemies that no longer exist?
The easiest way is probably to have something external telling them to attack. The enemy group for example could call i.attack() on each one in turn.
position = Vector2(0, index * 32)
i cant do this for some reason
ah
cuz it gives the resource allocation not the iteration number
forgot immediately
im cnofused on how to put for i in enemies.size() into a var
oh wait
sorry
im silly
instance.index = enemies.size()
nvm this sets it to the total size and not the current index