Page 1 of 1

Multi collision management

Posted: Wed Nov 22, 2006 12:03 pm
by Tonyx
Hi all,

i'm looking tutorials that show me how to manage a collision between maps and 3 objects.
Collision between map and player is easy to manage, but i have other 2 problems:

1) Collision between Player1 and Player2
Now when Player1 touch Player2, there is a mix of meshes, i don't want it.

2) Collision between Player1 bullet and Player2
How to make bullet hidden and decrement Player2 energy when there is a collision between Player2 and bullet?

I'have found some posts about ITriangleMetaSelector, but i have no idea how to use it, can someone help me with a short snippet, a short example?

Thank You
Tony.

Posted: Wed Nov 22, 2006 12:39 pm
by n00b
create triangle selectors to all your meshes.
create meta triangle selector.
use metaTriangleSelector->addSelector() to add all your triangle selectors.
then add meta triangle selector to camera collision response animator.

Posted: Wed Nov 22, 2006 6:52 pm
by Tonyx
Thank you n00b for your answer, but when a collision is detect between a bullet and a player i need to execute some istructions (like energy update ecc), there is an event or a method that alert me when this collision is detect ?

Tnx Tony

Posted: Thu Nov 23, 2006 11:17 am
by n00b
i'm not sure, cos i'm a n00b myself, but here's one way:
in the draw loop, check if the bounding box of the bullet intersects with the bounding box of the player, if true, then reduce the health etc.
i'm not sure if this is the best way to do it. You have to experiment yourself.

Posted: Thu Nov 23, 2006 11:51 am
by Tonyx
Thank you, i think you are right, but my problem is how-to detect:
n00b wrote:if the bounding box of the bullet intersects with the bounding box of the player
There is some method or event that do this?

Posted: Thu Nov 23, 2006 2:50 pm
by n00b
yeah there is, just store the bounding box of the player and the bullet in a aabbox3d<> variable.
the aabbox3d<> class has a function called IntersecsWithBox(aabbox<T>);
use that to check if the player's bbox intersects the bullet's bbox.

Posted: Fri Nov 24, 2006 5:33 am
by sgt_pinky
Tonyx,

If you go through the collision tutorial (I think tutorial 7 from memory), it shows how to do a ray/scenenode collision. Your ray is your bullet path, your scenenode is your player 2. You get out of it a coordinate position which is the intersection point.

Cheers,

Pinks

Posted: Fri Nov 24, 2006 8:08 am
by CodeDog
The real problem with ray collision in irrlicht is inaccuracy.
Typically it takes from 1 to 5 clicks on an object before you find the small sweet spot that will actually register a hit on a node.

Posted: Fri Nov 24, 2006 9:59 am
by Tonyx
sgt_pinky Thank you for your answer, but i have a problem with your solution.
My bullet has a speed, so if i shoot from large distance (using ray for collision) is possible that when the bullet arrive to target (player2), the target is not still in this position.

n00b thank you for your answer, i think is the best solution!!

Tnx guys, i'll try both solutions.

p.s. i'm sorry for my english, i hope you undestand.

Posted: Fri Nov 24, 2006 4:21 pm
by Tonyx

Code: Select all

core::aabbox3d<f32> boxbullet = bullet->getTransformedBoundingBox();
core::aabbox3d<f32> boxplayer2 = player2->getTransformedBoundingBox ();

if(boxbullet.intersectsWithBox(boxplayer2) == true) {
    sound_hit->play();
    .........
    etc. etc.
}
i've tried a similar code, and it work fine.

Thank you guys.