|
I have created one prefab of cube which is moving in one direction. now I want to apply Different characters to prefab at run time. I want different animals with some animation like walking in one side are to be generated with each instantiation of a cube prefab. So how to do it? can anyone help me with detail description and code
(comments are locked)
|
|
I have found it very useful to set up systems to do exactly what you are asking. By keeping the model separate from the prefab that represents game logic for an entity, you can apply that logic to any number of different models without duplicating that logic in a prefab for each model. You also gain the benefit of maintenance free model importing. If you change the fbx, there's no need to recopy it to another prefab as the dyanmic attaching of the model will always use the the most current model. Here is a simple example of how to get started with such a system. Attach this class to the prefab you want models to be attached to. Then, assign your potential models to the ModelPrefab array in the Inspector. The example chooses models randomly, but you could write a more specific selection method if you need to.
(comments are locked)
|

You can't modify prefabs at runtime. Just instantiate different prefabs, or have a single prefab with references to several mesh/material pairs.