ashurlee
Member
Can anyone see anything glaringly wrong with this code that could be causing collision checks to not always trigger?
This code is written in the hitbox for the ability. I have tried multiple solutions such as increasing the size of the collision mask. Clearing the list on creation. Increasing the time the hitbox is on screen before destroyed, and rewriting the code in the script that created it. None seem to work.
The reason for this code, is to allow the hitbox to only damage an enemy once, instead of continuously damaging it for the entire time it is created. It is supposed to, check if the enemy has been hit, if not, add it to the list, so that when it checks again and see's it is in the list, it does nothing. For the most part this works, but there will be times where the collision check do not register.
Thanks in advance.
This code is written in the hitbox for the ability. I have tried multiple solutions such as increasing the size of the collision mask. Clearing the list on creation. Increasing the time the hitbox is on screen before destroyed, and rewriting the code in the script that created it. None seem to work.
The reason for this code, is to allow the hitbox to only damage an enemy once, instead of continuously damaging it for the entire time it is created. It is supposed to, check if the enemy has been hit, if not, add it to the list, so that when it checks again and see's it is in the list, it does nothing. For the most part this works, but there will be times where the collision check do not register.
Thanks in advance.
GML:
//CREATE
hit_list = ds_list_create();
x = obj_player.x;
y = obj_player.y;
image_angle = obj_player.image_angle;
alarm[0] = 5;
//STEP
with instance_place(x,y,obj_enemy)
{
if ds_list_find_index(other.hit_list,id) = -1
{
ds_list_add(other.hit_list,id);
hp -= 60;
obj_player.rift_ammo_count += 2;
}
}
//ALARM 0
instance_destroy();
//DESTROY
ds_list_destroy(hit_list);