Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - elegantmechanic

#21
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
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.
SMF spam blocked by CleanTalk