Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mac on Thu 23/11/2006 03:47:06

Title: NPC collision to cause health loss [SOLVED]
Post by: Mac on Thu 23/11/2006 03:47:06
I've done a search but couldn't find anything relating to my particular problem. I have a health system in place as well as an enemy NPC that travels back and forth across the screen. I've used IsCollidingWithChar to subtract health when the NPC collides with the PC. However, when the collision takes place all of the health is taken out in one go (because the characters are still colliding as the NPC passes). How can I fix this?
Title: Re: NPC collision to cause health loss
Post by: Gilbert on Thu 23/11/2006 03:55:11
Use variables to keep track of that.

Something like (pseudo codes ahead, too lazy to muck up real working AGS codes):

if (char A and char B collides) {
  if (ABcol==0) { //only do once when they FIRST collides
      ABcol=1;
      decrease health;
  }
} else ABcol=0; //reset when the characters are away, so health will be decreased in next collision
Title: Re: NPC collision to cause health loss
Post by: Mac on Thu 23/11/2006 04:00:27
Thanks very much for your help :) Working loverly.