Summer Programming 2014 – Dev. Post 5

It took some time but I finally solved the Parent-Child issue with very little trouble.

Before I explain the problem I might need to explain the structure. You see, each object is, quite simply a basic object with a Parent and any number of children. These children are also game objects whose Parent is the first Game Object and can in turn have several children of their own. The children in question are stored as pointers in a vector and can be accessed via several methods.

The main problem was in deleting these children. When a child was about to be deleted (that sounds simply AWFUL out of context) it would call the parent and ask it to delete the child which in turn would make the child call the parent and ask it to delete the child which in turn would make the child call the parent and ask it to delete the child which in turn would make the child call the parent and ask it to delete the child which in turn would make the child call the… you get the point… This was, however easily fixed with a slight modification of the removal script.

There was, however, aa second problem that I encountered was how the children were handled. As they were removed their spots in the vector weren’t which lead to the game crashing when a certain number of objects had spawned and the game trying to update empty objects. The solution was to simply make sure that the objects are removed upon command. For this I used the erase() method of vectors which I haven’t actually used before. Aren’t vectors supposed to fix these issues by themselves? Either way it solved the issue and there doesn’t seem to be any direct errors with the parent-child system at the moment. I also decided to try using unique pointers instead of regular pointers for the children management but this does not seem to be of much benefit at the moment and I’ll probably switch back to regular old pointers there’s no point to it.

At the moment the only thing that’s left for this week is to develop simple enemy AI and Collision. out of these two the Collision will probably be the more challenging one as I have to check collision between several different objects belonging to several parents.

Anyway, I probably won’t get much work done tomorrow but I might post anyway. Good night.