Page 1 of 1

Simple collision Question.

Posted: Tue Sep 11, 2007 1:38 am
by iamtehpwn
Lets say I have two specific Scene Nodes.
A Sword, and an Enemy.
And I Want to check and see if they have collided with each other, but I can't find any function to do so.

I've read the irrlicht documentation up an down, and I still don't quite get what to do.

Posted: Tue Sep 11, 2007 1:49 am
by zeno60
If you know the players position (who i'm going to assume is swinging the sword) and the enemy position then you should be able to determine if the sword is going to hit or not. This would probably be the fastest solution as it only requires two values sent at a specific time. The other options would be using something like a bounding box around your sword and another bounding object around your enemy and comparing each during the fight. To go even deeper as to determine where the enemy was hit, you would probably have to delve into the vertex buffer to compare which points are closest to your sword edge.

Posted: Tue Sep 11, 2007 1:54 am
by iamtehpwn
Thats currently what I am doing. But This is a very flawed system, and does not support multiple enemies very way. While I could do this, my game would appear very bad, and I'm looking things to appear more clean.

Which is why I need to have sword-to-enemy collision.

Posted: Tue Sep 11, 2007 8:11 am
by rogerborg
Irrlicht supports line/box and line/mesh collisions via its collision manager. See example 07. Collision.

Unfortunately, it has no built in updating a triangle selector from an animated mesh. You could try this patch that I wrote last year, roll your own, or go with an external library like OPCODE or Newton.

Also: please search the forums; this question has been asked and answered comprehensively approximately 3,627,295 times before.

Posted: Tue Sep 11, 2007 11:37 am
by rogerborg
Right, I've updated and uploaded a candidate patch that enables triangle selectors to be built from animated mesh scene nodes. The selector will get updated automatically when necessary (i.e. when the animated mesh from which it's created has changed).

It still doesn't allow mesh-mesh collisions, just ray-mesh, but that should be sufficient for a sword; you just need to create a ray that represents the edge or centre of the sword.

Then you can do intersections trivially with getSceneNodeFromRayBB() and getCollisionPoint(). See the modified example 07. Collision for how to do that.

Posted: Tue Sep 11, 2007 10:02 pm
by iamtehpwn
Thank you.