Simple collision Question.

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
iamtehpwn
Posts: 30
Joined: Sat Mar 31, 2007 6:11 pm

Simple collision Question.

Post 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.
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post 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.
Last edited by zeno60 on Tue Sep 11, 2007 1:55 am, edited 1 time in total.
iamtehpwn
Posts: 30
Joined: Sat Mar 31, 2007 6:11 pm

Post 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.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
iamtehpwn
Posts: 30
Joined: Sat Mar 31, 2007 6:11 pm

Post by iamtehpwn »

Thank you.
Post Reply