I am using the following code to track damage to a character if they touch a hostile object. I want the character's health bar to decrease and the object to disappear.
Code: AGS
The problem I have is that, with the above code, the object disappears but the health value does not change. If I leave out the object line, then the health does change for as long as the character and object are colliding. So both lines work if used by themselves but not if used together.
I feel I must be missing something very obvious but can't find the solution in the many other collision threads in the forum.
if (cEgo.IsCollidingWithObject (object[0]) == 1) {
health-=10;
HealthBar.Width=health;
object[0].Visible=false;
}
The problem I have is that, with the above code, the object disappears but the health value does not change. If I leave out the object line, then the health does change for as long as the character and object are colliding. So both lines work if used by themselves but not if used together.
I feel I must be missing something very obvious but can't find the solution in the many other collision threads in the forum.