Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Help to add two new features

A topic by ThisHands created Jul 16, 2024 Views: 94 Replies: 1
Viewing posts 1 to 2

Hi, i would like to make it so the units that had a higher speed variable would go first instead of being random, i tried using array sort but i get this error 

############################################################################################ ERROR in action number 1 of Draw Event for object obj_battles: trying to index a variable which is not an array at gml_Object_obj_battles_Draw_0 (line 10) - var _unitWithCurrentTurn = unitTurnOrder[turn].id ############################################################################################ gml_Object_obj_battles_Draw_0 (line 10)

this is how i tried it: 

unitTurnOrder = array_sort(units, function(a, b){

return b.speeed - a.speeed;

}) (there's three e's on speed because the text would turn green).


The other feature i would like to add is to choose the actions first and then all the units do their actions. Thanks :)

Try adding it to a struct maybe? Either that, or check to see if the variables have been mentioned properly. It looks like as if the error is based on an undefined variable.

Hope that helps you.