instancing_continued.rst 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. .. _doc_instancing_continued:
  2. Instancing (continued)
  3. ======================
  4. Recap
  5. -----
  6. Instancing has many handy uses. At a glance, with instancing you have:
  7. - The ability to subdivide scenes and make them easier to manage.
  8. - A more flexible alternative to prefabs (and much more powerful given that
  9. instances can be nested).
  10. - A way to organize and embed complex game flows or even UIs (in Godot, UI
  11. Elements are nodes, too).
  12. Design language
  13. ---------------
  14. But the greatest strength that comes with instancing scenes is that it works
  15. as an excellent design language. This is pretty much what distinguishes Godot
  16. from all the other engines out there. Godot was designed from the ground up
  17. around this concept.
  18. When making games with Godot, the recommended approach is to dismiss most
  19. common design patterns, such as MVC or Entity-Relationship diagrams, and
  20. instead think about your scenes in a more natural way. Start by imagining the
  21. visible elements in your game, the ones that can be named not just by a
  22. programmer, but by anyone.
  23. For example, here's how a simple shooter game could be imagined:
  24. .. image:: img/shooter_instancing.png
  25. You can come up with a diagram like this for almost any kind
  26. of game. Write down the parts of the game that you can visualize, and then
  27. add arrows to represent ownership of one component by another.
  28. Once you have a diagram like this, the recommended process for making a game is
  29. to create a scene for each element listed in the diagram. You'll use instancing
  30. (either by code or directly in the editor) for the ownership relationships.
  31. A lot of time spent in programming games (or software in general) is on
  32. designing an architecture and fitting game components to that architecture.
  33. Designing based on scenes replaces that approach and makes development much
  34. faster and more straightforward, allowing you to concentrate on the game logic
  35. itself. Because most game components map directly to a scene, using a design-based on scene instantiation means little other architectural code is needed.
  36. Let's take a look at one more, somewhat more complex, example of an open-world
  37. type game with lots of assets and nested elements:
  38. .. image:: img/openworld_instancing.png
  39. Take a look at the room element. Let's say we started there. We could make a
  40. couple of different room scenes, with different arrangements of furniture (also
  41. scenes) in them. Later, we could make a house scene, connecting rooms to make
  42. up its interior.
  43. Then, we could make a citadel scene, which is made out of many instanced
  44. houses. Then, we could start working on the world map terrain, adding the
  45. citadel onto it.
  46. Later, we could create scenes that represent guards (and other NPCs) and add
  47. them to the citadel as well. As a result, they would be indirectly added to the
  48. overall game world.
  49. With Godot, it's easy to iterate on your game like this, as all you need to do
  50. is create and instance more scenes. Furthermore, the editor UI is designed to be user
  51. friendly for programmers and non-programmers alike. A typical team development
  52. process can involve 2D or 3D artists, level designers, game designers,
  53. and animators, all working with the editor interface.
  54. Information overload!
  55. ---------------------
  56. This has been a lot of high level information dropped on you all at once.
  57. However, the important part of this tutorial was to create an awareness of how
  58. scenes and instancing are used in real projects.
  59. Everything discussed here will become second nature to you once you start
  60. making games and putting these concepts into practice. For now, don't worry
  61. about it too much, and go on to the next tutorial!