As I talked yesterday about hierarchies and sounds, all of these things are implemented here.
Hierarchies will be useful for ship formations and large bosses.
Another previously (by me) unseen use of hierarchies is of course for collision detection.
Although it’s probably best to generally let small one piece objects deal with their own collision detection, larger more complex objects will certainly need several bounding boxes or spheres, and they will obviously be children to the object in question. They will pass down collision events to their father.
Right now I am struggling with a little issue here. Torpedoes from my own ship should not be able to hit other torpedoes fired from my own ship. Well torpedoes should not hit torpedoes at all, but if my ship has children, a torpedo fired by me should not be able to hit it (unless otherwise specified of course!)
So far, a child can never harm a parent and vice versa (what a beautiful world!), however a child can harm another child without any trouble (more realistic, less desirable). Of course, one can always go down the tree checking to make sure that both children do not have the same parent, but this might prove troublesome.
One idea might be to provide each object with unique shield frequency. Object that should not hit eachother would have the same frequency. This is a pretty bad idea I think, because torpedoes should not hit other torpedoes, but they should certainly be able to hit other ships.
So that idea falls short. It is a cool idea tho, I might use it for something.
Also, in an ideal hierarchy, each object should be a child of the SUPER OBJECT (in this case, the game world. This would serve a good purpose, such as if the world is moving, it would move all of it’s children. So just because things inherit from the same world, if they can not collide, this is a problem.
An alternative sollution is required.
Here are the variables that need to be considered:
1. Any object should be able to collide with another object
2. Any parent or child should decide if it should collide with its filials.
3. Same as above should decide if the collision will cause damage or do something else
4. Any object should be able to decide whom it can and can not collide with
5. Any object should be able to be out of phase, and thus not collide with anyone.
Solutions to the points:
1. This already works, but might need to be redesigned to accomodate new collision rules.
5. An invisible flag should exist, invisible objects can not collide with anything. Sounds will be invisible.
The other aspects are as of yet unsolved, but they will be in due time. I shall return when I have found a good solution.