3D Collision Detection

Started by
4 comments, last by MstWntd 15 years, 4 months ago
Sorry just realised, I posted my thread in the wrong session. And I cant seem to delete it! It should have be here, anyway http://www.gamedev.net/community/forums/topic.asp?topic_id=517296 can anyone help?
Advertisement
-------------------------

I have an Arrow which hits a barrel and is then stuck in the barrel

The barrel is positioned as x=300, y=0 and z=0.

but the problem is that in WHATEVER DIRECTION the arrow is shot in,
if its x is around 300 and its y and z are around the y and z of the barrel, it will detect it as a collision.

Also if i shoot the arrow well above the barrel, it will be detected as a collision.

it might be worth noticing that all of my game objects are on different matrix (each one pops and pushes for its own rendering)..but i dont know enough to know if that makes a difference.

I can post some source code, but that will have to be done when I get home.

Thank you.

---------------------------

Can someone please guide me in the right direction?..I am decent at programing, even in C++ but I am totally new to OpenGL.

And I have to hand this work in really soon. Please!
Hi

How are you doing the collision check?

Usually if its a barrel, people approximate it with a cylinder shape, and you can approximate your arrow with a box shape. Then usually the collision check happens between the cylinder and the box shape.

Then if you want your arrow to stick into the barrel (ie, cylinder shape), your engine/code needs to report a collision point in world space. You can then use the collision point to statically position your arrow.

Hope that helps.

ps,

By the way I may sound that is an easy task, but i have to tell you its anywhere but trivial. Collision detection has always been difficult.
It is hard to say without seeing your code, so here's my stab in the dark:

One of the steps in collision detection is to see if the arrow intersects the infinite PLANES of the barrels polygons. If it does, the system then checks if it is INSIDE the actual shape.

Perhaps your system is returning positive purely because the arrow intersects the planes of the barrel without checking the actual perimeters?

It could be anything though, depending on your code. Mickeyren is spot on for all of his points though, especially the difficulty. Collision detection has gotten the best of me many times! :). Don't be discouraged though.

Good Luck!
- Haptic
Come on, did i say some thing wrong in my post?
hey, sorry for my last post, i think this collision dection has me wacked out!

this is my collision detection code,

if (((mPosition - o->GetPosition()).Length() <= (o->size + size)) )
{
Arrow * a = (Arrow*)o;
a->setInFlight(false);
OnCollision(o);
return true;
}
return false;

the pointer o is the arrow object.

I dont really have any problem keepin the arrow stuck in the barrel,this i

basically, i set the inFlight of the arrow to false, this stops the Physics Method from makin changes to the X and Y of the arrow.

and then in the barrel class i render all the arrows in the barrel (kept in its own vector), before that i change the Z of each of the arrows to that of the barrel so it moves left and right with the barrel (my barrel is a moving target)

This topic is closed to new replies.

Advertisement