Hello. Suppose I was making a game like scrabble which has 26 game pieces, each one a different letter (A, B…). Instead of making 26 entities I could make one template and then clone it and assign a material. I also have 3 different models to differentiate some letters that fall in to some groups (lets say based on score). In terms of performance, what is the best strategy here when using a factory to clone entities?
If I had a factory method such as
var entity = LetterTemplate.clone();
var letterScript = entity.script.letter;
switch(letter){
case "A":
letterScript.setLetter("A");
// I could set the model based on the 3 attached model assets
entity.model.model = letterScript.modelLowScore.resource;
// And then set the material based on 26 material assets (although this doesn't work)...
entity.model.materialAsset = letterScript.materialA.resource;
}
I could set each model based on the “Letter” script which has 3assets of type “model” - one for each letter, and set the material based on the 26 attached material assets. My question is every time I clone this template entity, which already has 26 materials and 3 models, am I taking a huge performance hit, or is everything really just by reference?
Currently I actually made 26 templates for each letter and clone those, but it’s obviously a nightmare to do modifications on all 26.
Any help appreciated.