Generic collision detection using processes and collision - possible?

Started by Sslaxx, July 30, 2011, 02:34:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sslaxx

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; you must pass collision a valid process ID. Is this right?
Stuart "Sslaxx" Moore.

handsource-dyko

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.

Sslaxx

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...
Stuart "Sslaxx" Moore.