I am using GameMaker Studio 1.4. I have a fireball object, and when it collides with the enemy object, it is supposed to remove 1 (one) from the enemy's life variable.
Here is the code:
Fireball Code
Step Event
if (place_meeting(x,y,obj_enemy)) { // if collision with enemy
with (other) {
other.life-=1; // remove 1 from life
self.start_decay=true; // remove fireball
}
}
Enemy Code
Create
life=1;
isDie=false;
Step Event
if (life<=0) {
isDie=true; // I use a variable because there are other conditions that can also satisfy this
}
[...] // other unnecessary code
if (isDie) {
instance_destroy(); // Destroy self
}
Error Log(s)
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_fireball:
Variable <unknown_object>.<unknown variable>(100017, -2147483648) not set before reading it.
at gml_Object_obj_fireball_StepNormalEvent_1 (line 3) - other.life-=1;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_fireball_StepNormalEvent_1 (line 3) ('other.life-=1;')