Roastedzerg
Member
Hey gmc, Ive been having some lag issues in my game with vsync turned on (turning it off creates lots of tearing in the game, but it runs alot smoother with only a little lag) And i think it might be the priority queues i have set up in each enemy object to search for the player. Im sure its because there are multiple queues being made in one room, but thats what i had to do to make each enemy have their own mind instead of a hive mind.
Does anyone see anything in the following code that could be causing a huge drop in frames?
FYI i am indeed destroying the queue when the enemy object is destroyed
EDIT: Hmm just tried making it into an executable and it doesnt lag at all. only when im working on it in the IDE. Is this just a problem with GMS2?
Does anyone see anything in the following code that could be causing a huge drop in frames?
Code:
//Clear priority every step
ds_priority_clear(player_list)
//Add to enemy_list if we see a player
var i;
for(i=0;i<instance_number(obj_player_parent);i++)
{
global.player[i]=instance_find(obj_player_parent,i);
if(!x_ray_vision)
{
if(!collision_line(x,y,global.player[i].x,global.player[i].y,obj_block,false,true))
{
ds_priority_add(player_list,global.player[i].id,point_distance(x,y,global.player[i].x,global.player[i].y));
}
}
else
{
ds_priority_add(player_list,global.player[i].id,point_distance(x,y,global.player[i].x,global.player[i].y));
}
}
//Set our target
if(ds_priority_empty(player_list))
{
my_target=noone;
}
else
{
my_target=ds_priority_find_min(player_list);
}
FYI i am indeed destroying the queue when the enemy object is destroyed
EDIT: Hmm just tried making it into an executable and it doesnt lag at all. only when im working on it in the IDE. Is this just a problem with GMS2?
Last edited: