Question: How to get position of an enemy charcater body from an array
How to get position of a character body from an array? cause it doesn’t work for me I will send the screen shot but in short:
I set area 3d to detetct player when enters and put enemy (self) into a global array
and I go to player script where lockon system is writeen and I set target pos as enemy_onspot array
The problem is: it says the property transform doesn’t exist and when I add [0] it says out of border
The problem, I think, is you failed to consider what happens if you call Lockon() while the globl.enemy_onspot array is empty. That’s why you get an “out of bounds” error. You can check with globl.enemy_onspot.is_empty() before attempting to index into the array.
Yeah you are right I did similar thing to check
if !array.size() > 0:
Return
.
It worked and it was good thanks to that person on godot discord server that told me
And thank you