Hey brosephs,
For my final project in my programming class this year I am creating a first-person version of the popular flash game Boxhead, in which the player slays poop-tons of box shaped zombies. This game is gonna be incredibly epic, I've commissioned a composer to write an original score and everything. Anyway, I'm using irrlicht (obviously) and I am running into a spot of trouble handling the events of bullets crashing into walls. I'm using the scene manager's Collision Response Animator to collide the bullets with the walls, the thing is that I want to run my bullet delete subroutine as soon as this happens. If there is any way to get the nodes involved in collisions from the scene manager as soon as they happen, it would be much appreciated if somebody could point me in the right direction. If not, I'll just have to deal with these bullets sliding around my walls some other way.
Cheers
[/code]
Returning collisions
-
Lonesome Ducky
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
It's not a good idea to have the scene collision manager handle the bullets. Nearly every game will instead cast a ray when the gun is shot and see if it hits a character or a wall, and handles it accordingly. Bullets move so fast that this method acts far more realistically than the way you're doing it. And the way you're doing it often leads to bullets phasing through objects and is usually MUCH slower.
-
Thelollertruck
- Posts: 5
- Joined: Wed Apr 06, 2011 10:33 pm
Thanks, you're probably the tenth person to tell me so. I'm using the scene manager to handle bullets for a number of reasons though, the most important being that I'm using the same code to handle rockets and grenades as well as bullets, which move slowly. I do interpolate between the bullets' positions before and after each frame to check for collisions with stuff I've hitboxed, like enemies, shrubs, and lampposts, so phasing through stuff isn't a problem. I'd just like to know if what I'd like to do with the scene manager is possible, finding nodes that have collided.
With ISceneNodeAnimatorCollisionResponse::setCollisionCallback you can set a callback (a function or class-object that is called when something happens) in which you can handle the collision the moment it occurs. Create a class that derives from irr::scene::ICollisionCallback, overload onCollision and add an object of that class.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm