Hi !
I am trying to create a FPS but when my bullet collide a mesh I would like to know which mesh it was so I can decrease his health !
How could I know which mesh has been collide.
I use ITriangleSelector.
Maybe It's not a good thing?
Thanks
How to get the collided mesh ?
-
- Posts: 26
- Joined: Sun Jan 21, 2007 9:11 pm
How to get the collided mesh ?
Irrlicht 4ever.
What is your method of collision detection other than using a triangle selector? Presumably you have multiple nodes that the bullet can collide with.
One thing you could do is for each bullet iterate through all the players checking the bullet against the player's triangle selector, then you'll know which one has been hit.
One thing you could do is for each bullet iterate through all the players checking the bullet against the player's triangle selector, then you'll know which one has been hit.
It isn't really good enough to test the position of the bullet against the player triangle selector. Remember that the simulation runs at discrete intervals depending on the frame rate. At 60fps, the physics run every 0.0167 seconds. A bullet travelling at 600 ft/sec will go 10 feet in that time.
If you just do discrete collision detection every frame, the bullet may have passed through the model since the last time you did collision detection.
Ideally you would take the previous position of the bullet and the new position of the bullet and create a line segment. Then you'd do collision testing on that line segment. For efficiency you would want to check the nodes bounding box against the ray [possibly using getSceneNodeFromRayBB()] and if that succeeds, you would want to do the more expensive mesh to ray collision test [with getCollisionPoint()].
Travis
If you just do discrete collision detection every frame, the bullet may have passed through the model since the last time you did collision detection.
Ideally you would take the previous position of the bullet and the new position of the bullet and create a line segment. Then you'd do collision testing on that line segment. For efficiency you would want to check the nodes bounding box against the ray [possibly using getSceneNodeFromRayBB()] and if that succeeds, you would want to do the more expensive mesh to ray collision test [with getCollisionPoint()].
Travis
-
- Posts: 26
- Joined: Sun Jan 21, 2007 9:11 pm
Thanks.
Actually I guess It's gonna be hard to use this method because the collision are calculating inside the server so that nobody can hack.
Which method would be better?
I guess getCollisionPoint would be efficient but I never used it so I don't know how it does work.
maitrelame2
Actually I guess It's gonna be hard to use this method because the collision are calculating inside the server so that nobody can hack.
Which method would be better?
I guess getCollisionPoint would be efficient but I never used it so I don't know how it does work.
maitrelame2
Irrlicht 4ever.