H
Hoon Shuber
Guest
I have a global enemy array in the room creation code with one value being enemy spawn chance:
global.enemy_array[0, 6] = 2; // Spawn chance in %
I have the following code in my level creation object (run just after the creation of the floor tiles in a ds_grid) which is supposed to pick a random enemy, get the odds from the array, and then create the enemy based on the odds.
var enemyid = irandom(1);
var odds_enemy = global.enemy_array[enemyid, 6];
if (point_distance(ex, ey, obj_player.x, obj_player.y) > 80 && irandom(100) <= odds_enemy)
{
instance_create(ex, ey, obj_enemy);
}
The error I get is this:
FATAL ERROR in action number 1 of Create Event for object obj_level:
trying to index a variable which is not an array at gml_Object_obj_level_CreateEvent_1 (line 157) - var odds_enemy = global.enemy_array[enemyid, 6];
I'm not sure what the issue is since the array is declared during the room creation and before the building of the level.
Any help would be appreciated. Thanks
global.enemy_array[0, 6] = 2; // Spawn chance in %
I have the following code in my level creation object (run just after the creation of the floor tiles in a ds_grid) which is supposed to pick a random enemy, get the odds from the array, and then create the enemy based on the odds.
var enemyid = irandom(1);
var odds_enemy = global.enemy_array[enemyid, 6];
if (point_distance(ex, ey, obj_player.x, obj_player.y) > 80 && irandom(100) <= odds_enemy)
{
instance_create(ex, ey, obj_enemy);
}
The error I get is this:
FATAL ERROR in action number 1 of Create Event for object obj_level:
trying to index a variable which is not an array at gml_Object_obj_level_CreateEvent_1 (line 157) - var odds_enemy = global.enemy_array[enemyid, 6];
I'm not sure what the issue is since the array is declared during the room creation and before the building of the level.
Any help would be appreciated. Thanks