Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm following this tutorial by thecplusplusguy and in the linked video he explain that for example for the world basement and walls we need to create the actual rendered (shown to the player) walls and then duplicate them, place them in the same coordinates as the rendered walls and call them collision (by defining their material to collision). Then it defines in the Object loader function that those objects with material == collision are collision planes and should not be rendered but just used to check collision.

Now I'm pretty confused. Why would we add this kind of complexity to a problem that can easily be solved by a simple loadObject(string plane_object, bool check_collision);:

  1. Creating only the walls object (by loading .obj file in plane_object)
  2. Define them also as collision planes whenever the check_collision is set to true

In this case we have lowered the complexity of his method and make it more flexible and faster to develop (faster because we don't always have to make a copy for each plane and flexible because we don't hardcode the Object loader). The only case in which this method could not work is when we need hidden collision planes, and for that we could modify the loadObject() function like this: loadObject(string plane_object, bool check_collision = true, bool hide_object = false);

  1. Creating only the walls object (by loading .obj file in plane_object)
  2. Define them also as collision planes whenever the check_collision is set to true
  3. And add the ability to actually show the object or hide it based on hide_object.

The final question is: am I right? What would the possible problem encountered with my solution versus his?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

While your solution would certainly work, and make for simpler Object files, it will mean that for every level you need to add in extra code whenever you want to add or remove collision objects.

If the collision object generation is handled completely by the Object loader, then your level-designer can create and modify levels without involving the programmer or forcing a rebuild of the engine. This is very important, since a huge part of creating a game (>90%) is making assets and levels.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.