This is not related to blend trees btw (is unbelievable the amount of question people do about it).
So, I’m pretty confident on my skills levels on scripting, and I could achieve great progress on what I’ve proposed, just wondering something.
I’ve been watching tons of videos, for example from Jason Weimann, and in those videos he describes sometimes a good practice. The last example that comes up on my mind is to have a prefab as a empty game object, then insert inside (if it is the player prefab), the skeleton and others game object we could need from that prefab.
Saying that, I wonder how should I structure my prefabs?
Right now, I’ve tried that most of my component are placed on the first game object, so you can know easily where to look when some defect appear. This could look good but I’m fighting against the product too (for example, humanoids will always have an animator inside even if you disable them, and I’ve been disabling that)
I can’t find a really good place where to read about this things, scene setup is something I totally lack of knowledge and I’d really like to start learning.
Btw, thanks and sorry for the big text.
TL;DR: I want to know where should I read about best practices on scene setup (and prefabs).
I didn’t mean to say there is something WRONG. What I tried to say is what is the best practice?
What do you follow as standard when you are developing a game?
How do you avoid future problems trying to understand a prefab (That you may not made)
And so on…
From your first post, I’m not quite sure about whether you’re talking about how to arrange components on a complex GameObject hierarchy. or how you go about arranging the different game objects in your hierarchy into separate prefabs, or maybe both? In either case, I don’t think you’ll see much guidance about it, simply because there is no “best practice.” The idea with these constructs is to be super flexible so that you can structure your project however you want.
As for components, you really just put components on whatever GameObject they need to be on, and that’s all up to you and your project and what problems you’re trying to solve. I don’t think there’s a right or wrong way, necessarily, but people do tend to put components on the root object where they’re easy to find. For a character, I tend to put “controller” components that control the overall character on the character root- things like the CharacterController, Whatever handles input, animation state controller, stuff like that.
There are things that don’t necessarily work on the root, like the animator as you’ve already discovered. Or maybe your head-look controller should go on the head. Maybe your character has a sword. It’ll probably be attached to the hand, deep in the hierarchy, but will probably need it’s own scripts and it’s own collider and maybe rigidbody. You can’t really force an all components-go-on-the-root rule, since that often doesn’t make sense.
As for prefabs, that’s also arbitrary.
If you take your example here:
It’s actually the common scenario in Unity that the animated skinned-mesh is a child of your character object, but that doesn’t necessarily mean that you need to have a separate prefab for each. It sounds like in his case, he had multiple characters that functioned the same but had different character models, so in his project it made sense to have a separate prefab for functionality and visual representation. This is just one specific scenario with one specific goal, though. This strategy is not going to make sense in every case.
I’ve done the same thing in my project with my two player characters. They are exactly the same and only look different. The player is actually just a character controller with all of the necessary components (that’s one prefab that reuse for each character) and then there’s a child hierarchy that has the animator and skinned mesh components and what-not (2 prefabs, one for each character).
My NPCs have the same type of object hierarchy, but for each NPC the components on the root object are each configured very different from another NPCs, so for each NPC, I only save one prefab that has all of that NPCs objects. Different scenario. Different strategy.
Just like with code, you might have to stop and refactor your design. Move stuff around. Don’t spend too long over-thinking it because it’s hard to predict what your going to need until after you start implementing.
@kdgalla thanks for your reply, I get your point and makes totally sense when reading.
I am so bad at game object design (and level design or sscenario design and so on…)
I always scripted and I can actually make a good architecture on this area, but now that I’m pretending to learn all of that, I’ve gotten a lot of questions.
Thanks for clarify, I will try to create a new post with more accurate questions if they come up