How to make (Child - Attach) system with Item type

Started by
1 comment, last by LorenzoGatti 6 months ago

Hi guys,

I'm designing the system of the engine, and I started to work with class Item (basically, you can equip the item, and it will replace the model, example if I equip some pants, I will get the model from the ItemID, hide current pants and show the equiped pants model).

My issue come's when I think how to do it. Because I have a little Entity like system, I have a base class (Entity) and a few that inherit from it (example Model which it's only purpose is to render the model), now with the Attach system, I could in theory attach 3 Models to any Entity, now if I have a Player, and I equip a new item, how should I handle it? Because, in theory, if I have 2 Models, which one will be replaced? Also, Item it's the child of Player, not child of Model, I need to retrieve data from it so I can make parts of the base model invisible, so the item should be attached to the Player or the Model? Also, Item should be a class of it's own, or just create “Model” for the Player to replace parts of the base model?

One idea that I came up with, is to create a new variable to the Entity base class, call m_baseModel, and I load directly from a new function, so even if new models are attached, only 1 will be the base, and I can hide from Item to the base.

Thanks!

Advertisement

It isn't very clear: are the 3D models for one character a set of separate objects (e.g. body, shirt, pants, shoes) that can be rendered independently or a consolidated complete model that you need to assemble from parts at runtime?

In the first case, the different pieces are actually different types belonging in separate “slots” (current body model, current shirt model, current pants model…), not a collection of indistinct objects; in the second case, there is only one model at all times and replacing the pants shouldn't complicate rendering.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement