Overview:
Can use inner/outer boundary box.
Outer detects collisions for outer walls of a room.
Inner detects collisions which take place when charactor comes acrossed an object in the room, such as another charactor, or table.
Simple Rules:
Movement should be restrained so as not to allow charactor to cross over an
object in a room.
Charactor should not be able to move past outer walls.
Boundary Box:
Setup an imaginary box, then type in coordinates, eg. upper/lower/left/right borders and if charactor comes near, do not allow it to pass, yet allow it the ability to move in other directions as long as it doesnt come across another boundary.
4 direction charactor movement outer boundary detection:
Take for instance you move charactor up, your upper boundary for the rooms back wall is at Z+ (12.0F) your charactor should not pass 12.0F, and no longer be given ability to move up once the upper bound has been reached, yet the charactor should be allowed to move left, right, or down.
All 4 directions must be treated this way.
Inner boundary detection:
Your charactor should not pass the boundary of another object in the room, yet should be allowed to move around the object.
For example:
Object is at center of room, the right side of the object is boundary X+ (1.0F), if your charactor moves towards the left, it should no longer be able to move once the charactor reaches the right boundary of the object in the room. Yet, the charactor should be allowed to be able to move up, down, or right.
Do test for each direction your charactor moves.
Basically you are comparing your charactors position with that of the defined object boundaries.
Testing multiple objects in room:
Store a list of boundary structures for each object in the room/level, everytime the charactor moves in any given direction, check each boundary value in the list to see if a collision has happened.
Projectile:
Lets say we want to fire projectile at object in room, you want it to test for boundary collisions the same way as if it were the charactor moving, when the projectile reaches an objects boundary, have it perform some action.
To return which object was hit by the projectile, simple return the name of the object that is linked to the boundary that was hit.
Charactor interaction/menu activation:
If you were playing an RPG youd know that when your charactor comes face to face with another charactor or object in the scene, a menu may popup or charactor dialog, so how is this done?
Simple, the same as with the other methods, when your charactor comes accross the boundary of another object, a message can be displayed then to indicate further action, for example:
Your charactor moves up and hits the lower boundary of a genie, the genie asks you what you wish, you give keyboard or mouse input to make your choice, then you go from there.
Well, hope all this has made some sense so far, goodluck!