Coded Games
Member
So after taking a few month break from using GameMaker to using Java instead I'm having trouble figuring why objDamagable's hp is not being decreased. objDamagable DOES have hp defined in it's create event but for some reason, it's not going down.
It's giving me an error saying both target and target.hp are unknown variables.
Code:
//Trance Max Distance
while (distance < maxRange && !hit) {
//Detect hit.
var xx = x + lengthdir_x(distance, angle);
var yy = y + lengthdir_y(distance, angle);
if (collision_point(xx, yy, objDamagable, false, true)) {
var target = instance_place(xx, yy, objDamagable);
target.hp -= damage;
hit = true;
break;
}
distance++;
}