Link
2. Live nested adaptable prefabs and templates
Live prefabs and templates
Most projects have recurrent elements.
For example, the same character is placed many times in a scene
or in multiple levels.
Just copy-pasting the character definition has the disadvantage
that modifying the character definition later
would require to adjust also each copy you have made in the meanwhile.
This is no option for any sophisticated project.
Shark 3D provides you prefabs and templates as solution.
You can combine any scene elements and nodes into a prefab or template.
Then you can use that prefab multiple times within our project.
If you change the prefab later, all usages of the prefab
will change accordingly
live.
For example, you can define a character type
containing geometry, animations, physics, sensor volumes
and behavior defined in scripts.
Then you can place that character multiple times in your scene.
If you move a sensor volume within the character prefab later,
then the sensor volume will move
live
for every instance of that character in the level.
Nesting live prefabs and templates
Typically just simple single-level prefabs are not sufficient.
For example, you might need different kinds of characters,
each instantiated multiple times in your scene.
You can do this by defining a prefab for each character kind.
The different character kinds may have common characteristics,
for example the same sensor volumes connected with the same
basic behavior script.
So for creating a new character kind you could just copy paste
an existing character kind and make some adjustments.
However, this again would have the disadvantage
that modifying a shared feature later would require
to modify it in each character prefab again.
As solution, in Shark 3D live prefabs and templates
may contain other live prefabs and templates.
You can nest prefabs and templates as often as desired.
Any change in any prefab or template will be used
live.
For example, you may create a template containing shared features
like some basic sensor volumes, some standard animations,
and a script defining basic behavior.
Then each character prefab may use that basic template,
but also add special features for that particular character kind.
For example, a character kind may have additional animations,
additional sensors, or an additional script for custom behavior.
Then you can instantiate each of these character prefabs
at multiple places in your scenes.
As result, if you for example move a sensor volume in the basic template,
then it will move
live for all characters in the scene
which are indirectly based on that template.
All this can be done graphically without any scripting or programming.
Live adaption of prefabs and templates
Often it is too restrictive to use prefabs and templates
just as they are.
For example, a character template may contain a sensor
sending a command to a script,
but the script should be not defined within the same template,
but the user of the template wants to define which script to use.
In Shark 3D you can easily adapt prefab and template by using slots.
For example, the character template may just define and use a slot
as placeholder for a script.
The user of that template can define which script should be used
for that slot.
Slots can be used for any kind of nodes,
including for example geometry, animations, scripts, sensors, or shaders.
Also slots can be used graphically without any scripting or programming.
Slots are also
live and can be changed afterwards.
Internally optimized for run-time performance
Internally, to get optimal run-time performance without bothering the user,
prefabs and templates are automatically resolved on the fly
into
optimized run-time representations.