Search code examples
debugginggame-makergml

Error on collision between Player and Enemy


I'm running into an error when I collide with an enemy. I'm not sure if it happens when I touch it or when I take damage from it. Heres the error message:


#

FATAL ERROR in action number 1 of Step Eventobj_player for object obj_damage:

Variable < unknown_object >.y(1, -2147483648) not set before reading it. at gml_Object_obj_damage_CollisionEvent_1_1 (line 6) - var dir = point_direction(creator.x, creator.y, other.x, other.y);

#

Heres the collision event for obj_damage with the obj_player:

if(other.id != creator) {
obj_player_stats.hp -= damage;

/// Knockback
var dir = point_direction(creator.x, creator.y, other.x, other.y);
var xforce = lengthdir_x(knockback, dir);
var yforce = lengthdir_y(knockback, dir);
with (other) {
    physics_apply_impulse(x, y, xforce, yforce);
}
}

Any help appreciated, I will provide extra code if necessary to fix. Thanks.


Solution

  • Fixed on my own, had a typo in my enemy collision with player, i put damage_creator and not damage.creator . I completely missed that when I was debugging, well you learn from mistakes (I am a newbie). Thanks for the help anyways.