hello guys, I have a doubt about my Hitbox code.
I made a code for the player to create a square, and if that square hits an enemy it does damage and pushes. In short, the code does this (I'll put it down here for a better understanding):
well, I tried to use llengthdir_x () and lengthdir_y () to push it, but it didn't work. On the other hand, he takes damage and loses life which is a good thing but I would like my character's blows to push the enemy away, but apparently he doesn't do it and I don't really understand why. If anyone can explain it to me, I am very grateful
I made a code for the player to create a square, and if that square hits an enemy it does damage and pushes. In short, the code does this (I'll put it down here for a better understanding):
GML:
//STEP EVENT
var lista_dano = ds_list_create();
// If it was the player who created me, I don't need to find him
if(!player_check)
{
var col = instance_place_list(x,y,obj_entidade_inimigo,lista_dano,false);
}
else
{
var col = instance_place_list(x,y,obj_player,lista_dano,false);
}
// perform the damage
if(col)
{
var tam = ds_list_size(lista_dano);
for(var i = 0; i < tam; i++)
{
// here the code manages the damage
var outro = lista_dano[| i];
// sure it doesn't affect my creator
if(outro != pai)
{
outro.hp -= dano;
}
}
}
// ensuring the list will not be kept in memory
ds_list_destroy(lista_dano);
instance_destroy();
well, I tried to use llengthdir_x () and lengthdir_y () to push it, but it didn't work. On the other hand, he takes damage and loses life which is a good thing but I would like my character's blows to push the enemy away, but apparently he doesn't do it and I don't really understand why. If anyone can explain it to me, I am very grateful