Multi collision management

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Tonyx
Posts: 14
Joined: Fri Mar 11, 2005 5:13 pm

Multi collision management

Post 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.
n00b
Posts: 58
Joined: Tue Sep 05, 2006 3:00 pm
Location: Earth
Contact:

Post 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.
Last edited by n00b on Wed Nov 22, 2006 12:39 pm, edited 1 time in total.
Tonyx
Posts: 14
Joined: Fri Mar 11, 2005 5:13 pm

Post 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
n00b
Posts: 58
Joined: Tue Sep 05, 2006 3:00 pm
Location: Earth
Contact:

Post 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.
Tonyx
Posts: 14
Joined: Fri Mar 11, 2005 5:13 pm

Post 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?
n00b
Posts: 58
Joined: Tue Sep 05, 2006 3:00 pm
Location: Earth
Contact:

Post 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.
sgt_pinky
Posts: 149
Joined: Sat Oct 14, 2006 11:20 am
Location: Melbourne, Australia

Post 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
Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
CodeDog
Posts: 106
Joined: Sat Oct 07, 2006 8:00 pm
Location: CA. USA
Contact:

Post 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.
Tonyx
Posts: 14
Joined: Fri Mar 11, 2005 5:13 pm

Post 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.
Tonyx
Posts: 14
Joined: Fri Mar 11, 2005 5:13 pm

Post 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.
Post Reply