I have collision detection working. This statement is completely true. Of course, it doesn’t DO anything when it detects them, it just kinda notes they happened. That’s probably a problem
However, I’ve got a solution. I have to abstract out movable objects and push their movements (and pan, tilt, etc) into it. And then those movable objects can remember their last move and be sent a ‘bounce’ message to undo it. Should work great, actually - in the case of the player, the collision box is ahead of the camera, so THAT shouldn’t clip. And in the case of NPCs, well, their steering behaviour will use raycasting in front of them, so they should never bump into anything anyways and the bounce is just a ‘just in case’ thing for them.
Still… progress!
What are you using for CD? And how much motion are we talking about– are you doing simple movement or actually simulating newtonian physics?
I remember tying in a CD library– well, a solid body modelling lib– into my grav tank “gamelet”. It did take a fair bit of work, building in all the linkage to have a solid body representation of my scene. But it worked a treat.
The graphics library (Ogre) that I use has an ‘IntersectionQuery’ method that can call a user-defined function for every intersection of ‘Entities’ in the scene. So right now, that user defined function just prints to console when stuff happens, but it’ll be able to call a bounce method on the entity. (well, I’ll actually have to wrap the entity, but that’s the general idea)
ok, so not solid body modelling but more simple collision detection– I must remember that the two are not the same.
So you really do have to answer the question of “what happens when an intersection happens”, rather than feeding mass and material information to a physics engine and have it decide what to do.
Yes. There are physics engines that plug into Ogre (3 or 4 different choices of engines, in fact), but the style of game I’m making doesn’t require physics and I’m going simple in the collision detection department. Essentially, I want to make sure the player (and NPCs) can’t walk through walls, the furniture or each other - that’s it. I don’t need bouncing objects, I don’t need gravity, I don’t need any of the standard physics stuff. I wanna make this simple and clean and then get on to the stuff I DO need - like dialogue trees and NPCs that walk around and objects you can put into inventory and use and.. and.. and..
I was kinda tempted by physics, but I figure I have to be ruthless and cut what I don’t NEED, if I’m ever going to get what I DO need done.
Aye.
What about pathfinding? How dynamic are your NPCs?
I’ll divide the place into rooms. I’ll use A* to go between rooms (I’ve played with A* before, it isn’t hard) and I’ll use steering behaviour within the rooms (essentially, they’ll walk towards whatever the goal is, using obstacle avoidance). Steering behaviours have some problems (with concave obstacles), but I can make sure there aren’t any in the level design.