Game help

Hey! I'm helping a friend with a game and i have a very BIG problem. I have to check if the object1 is over the object2 (object1 collide with object 2).
note:on the code below i will skip some lines of my original code
1
2
3
4
5
6
7
IModel* Marble = marbleMesh->CreateModel(0, 0, 0);
IModel* Mushroom1 = mushroomMesh->CreateModel(-70, 0, 90);
//here i get the coordinates of the marble after moving around
  Dx = bullet->GetX() - marble->GetX(); 
  Dz = bullet->GetZ() - marble->GetZ();
//next i have to check if the coordinates of the marble are
 the same of the mushroom but i don't know how to do that 
Last edited on
1
2
3
4
5
if (bullet->GetX() == marble->GetX() && bullet->GetY() == marble->GetY()) {
    float bz = bullet->GetZ();
    float mz = marble.GetZ();
    return bz >= mz ? 0 <= bz - mz && (bz - mz) <= someThreshold : false;
}


So as you can see to do this correctly, you need to define some threshold to be distance that the bullet must be from the target to correctly say that a hit has occurred.
This threshold value should be the maximum distance the bullet moves for each tick of the game.
hi! the bullet is the same object with the marble...i have to find if the marble-bullet collide with the mushroom. I'm trying to find a way so i can get the x and z of the mushroom and check if the marble coordinates are the same with the mushroom coordinates....
for example:
these are the coordinates of the mushroom
 
IModel* Mushroom1 = mushroomMesh->CreateModel(-70, 0, 90);

i move the marble-bullet and i have to find if the marble-bullet has collided with the mushroom
Last edited on
Topic archived. No new replies allowed.