any idea about dynamic collisions???

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
freestyle
Posts: 4
Joined: Wed Mar 10, 2004 6:13 pm

any idea about dynamic collisions???

Post by freestyle »

i need some code for checking collision bettween the bullets and the player
if u have some please send
it's an urgent problem
please help...
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

This should be in the beginners forum I think :)

Basically, you need to keep an array of all your active bullets (adding and deleting as nessecary).
You iterate through that array, and compare each bullet's bounding box with the player bounding box. If one overlaps, then a bullet has hit the player.
freestyle
Posts: 4
Joined: Wed Mar 10, 2004 6:13 pm

Post by freestyle »

ok...
but how can i compare bounding boxes?
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

Easy. Read the help, that's what I did.

Here's a snippit from my code, where I do bounding box collision between the "sydney" model, and the "faerie" model;

Code: Select all

if (sydney->getTransformedBoundingBox().intersectsWithBox(faerie->getTransformedBoundingBox())){
    printf("collision\n");
}
Something that tripped me up at first is; you can't used getBoundingBox, because it only returns the size and position the bounding box was when the model was loaded. You need to use getTransformedBoundingBox, to get the one that actually represents where they really are and their current size.
Post Reply