NPC collision to cause health loss [SOLVED]

Started by Mac, Thu 23/11/2006 03:47:06

Previous topic - Next topic

Mac

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?

Gilbert

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

Mac

Thanks very much for your help :) Working loverly.

SMF spam blocked by CleanTalk