Bennu Game Development

English Forums => Helpdesk => Topic started by: Sslaxx on July 30, 2011, 02:34:55 PM

Title: Generic collision detection using processes and collision - possible?
Post by: Sslaxx on July 30, 2011, 02:34:55 PM
So... I'm working on collision detection. I was using sensors.

What I'd like to do is something like this:

CollWith = collision (0); // Collision with any type of process.

...

if (CollWith == type EnemyFlying)
...


In other words, having a variable that holds the process id of anything colliding with that process, and having it dealt with later on. The thing is, the collision documentation indicates that this is not possible (http://wiki.bennugd.org/index.php?title=Collision); you must pass collision a valid process ID. Is this right?
Title: Re: Generic collision detection using processes and collision - possible?
Post by: handsource-dyko on July 30, 2011, 04:35:44 PM
Try this:


PROCESS player();

PRIVATE

int id2;

BEGIN

     IF (id2=collsion(TYPE enemy))
          // do something
     END
END


Id2 should now contain the id code of the process that collided with player process.
Title: Re: Generic collision detection using processes and collision - possible?
Post by: Sslaxx on July 30, 2011, 04:57:52 PM
I was thinking something more along the lines of:

while (1)
CollWith = collision (0); // If this process is colliding with anything, CollWith will store the ID of the process being collided with.
if (CollWith != 0) // Do something if CollWith is non-zero, i.e. a collision has happened.
  if (CollWith == type FlyingEnemy) // If collided with this type of process...
   ...
  end
end
end

From what I understand it doesn't matter what parameters you pass collision, yes? That said, I have doubts about the "if (CollWith == type FlyingEnemy)" line...