Game Development Community

Purpose of Templates

by Patrick Li · in Torque X 2D · 05/01/2008 (10:25 pm) · 1 replies

Hi,
I just downloaded and read the introduction to Torque X. I'm very impressed with the Component structure that Torque X has set up. However I'm confused about the purpose of the Template system.

To create a whole bunch of the same sort of objects, why can't I just use a static factory method?

ie. Monster createMonster()
-Create BaseActor
-set actor type to Monster
-add components
-return actor

Is there any advantage to using templates?

#1
05/02/2008 (2:45 am)
The most obvious advantage is that you can use the TXB GUI to build / modify the templates. It may not sound like much, but once you have a dozen characters and suddenly you have to tweak all their linkpoints to match some new art, you're going to wish you didn't have to build and run your project every time you want to see any little change you make.

Secondly, you need to separate your data from your code. Even a small game is going to contain hundreds of data values. Collision poly vectors, linkpoints, materials, names, physics values, etc. The list gets large very quickly. Given the slick XML deserialization TorqueX does there's just no reason not to separate your data. Load your templates from XML, then clone the templates.