I’m trying to add units to array as soon as they are summoned i want each of them to move to a unique location in the order of their summoning. Is there any way to find the latest summoned unit? Thanks In Advance
Nevermind I got it xD Please Remove This Post
It’s generally a good idea to explain how you got it. That way other users who might be looking for the same answers don’t have to make new threads.
I’ve found that this works:
latest = self.built[len(self.built)-1]
Actually my method is a little different. I found out that the units we summon will always be arranged in the order they are summoned like if there are already 5 soldiers on the field and i summon one archer and one griffinrider then the archer will be the 6th and the griffinrider will be the 7th. Hence The Latest Summoned Unit Will Be The Last In Friends Array. Sorry For Not Sharing My Findings I thought it was basic stuff which everybody already knows.
loop: summon("soldier") friends = findfFriends() lastIndex = len(friends) latestSummoned = friends[lastIndex}
Yeah, that’s one way to do it. That will only work if none of the friends have died, though, whereas the
built array still keeps dead units, so it won’t move around on you.