Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: SpastikChuwawa on Wed 08/07/2009 04:01:13

Title: Problem with Collision Detection [SOLVED]
Post by: SpastikChuwawa on Wed 08/07/2009 04:01:13
 I've been working on my first real AGS game after messing around with the program for a few years (!), and I came across a programming problem I can't seem to figure out.


In my sorry excuse for a puzzle, the player plants a banana peel on the ground so that the enemy walking towards him will stop in his tracks and slip.

Here's my code, the chef is the enemy character:

cChef.Walk(cChex.x+150,cChef.y, eNoBlock, eWalkAnywhere);
if (oBanana.PPCollideswithC(cChef)){
Display("He slipped!");
}

The problem is that the Chef walks right over the banana and goes on his merry way. I'm thinking the problem may lie with the Walk command, but I'm not sure. Any help would be mucho appreciated.

Oh, and I'm using the pixel perfect collision module.
Title: Re: Problem with Collision Detection
Post by: R4L on Wed 08/07/2009 05:46:59
Make sure you do a X and Y coordinate check. Well, that's what I would do to make sure it works.
Title: Re: Problem with Collision Detection
Post by: Gilbert on Wed 08/07/2009 06:39:28
Where did you put that part of codes?

You need to check the collision continuously, otherwise the check is only on the instance the character starts to walk.

Move the if (){...} collision part to repeatedly_execute() and see if it works.
Title: Re: Problem with Collision Detection
Post by: SpastikChuwawa on Wed 08/07/2009 14:32:08
 Yeah, I was messing around with the code some more, and it worked once I plopped it in repeatedly_execute. Thanks for the help though, guys. :]