#GameObject visuals with Unity.Physics and Entities

1 messages · Page 1 of 1 (latest)

humble pecan
#

In the interim of transitioning knowledge from GameObjects to Entities, Is it a valid design to have GameObjects just for the static visuals, and use Entities physics and other things? What is the guidance with this?

timber relic
#

Usually game objects are only used for animation, because that's the only thing that requieres paid assets atm for pure entities

#

Don't see any benefit of go for static

#

Entities.Graphics are much more efficient in every way for that purpose

humble pecan
#

I see. One challenge I can't seem to find an acceptable work around towards conversion to Entities is this: think of a city-builder or sim game where you place structures. I use GO prefabs that have the actual structure model, plus a bunch of extra gameobjects that help determining if the placement of the structure will be valid, such as markers if part of the structure is within acceptable limits above/below terrain, borders around the structure to help ensure the next structure placed does not impede other structure's space, position markers for POI spots within the structure, to name a few common and easily understanble ones. You can imagine that each prefab is curtailed for the specific structure model it contains, which means different shapes/configuration of the building, single to multi level, etc. When the structure is finally placed having passed all requisites, the placement of the structure discards all unnecessary items from the prefab, leaving on what's necessary.
In entities, I struggle to find all the empty gameobjects that contain specific children gameobjects under it, and although I've made the gameobject hierarchy as neat as possible for the prefab, it is still fairly nested.
Can you point me to how I can navigate the prefab Entity, navigate and destroy children objects and components (though I've got a good handle on finding components) like how I would if it was a gameobject? I just find this part very cumbersome when it comes to an entity prefab.

timber relic
#

Mixing game objects and entities for logic is going to be nightmare

#

Why not just fully work as entities

#

you can bake your building prefabs into absolutely any set of components you want

#

so it should contain enough information of how it may be placed in your world

#

And all that informatian will be on top level entity

humble pecan
timber relic
#

You can bake all info you need on root entity

humble pecan
# timber relic Forget the children, hierarchies are bad with ecs

Hmm interesting suggestion I've not considered! Let me see how I can go about this. Mind you, I'm dependent on the GameObject that a designer would still need to put together. With that said, are you suggesting that when I bake the GO Prefab (and eliminate the use of gameobjects altogether), that all the components and the data of all the children gameobjects be baked in the single entity prefab?

timber relic
#

Root entity should be enough

#

Childs should be on their own

#

graphics for example

#

In which case you never need to access them, since they follow root on their own

humble pecan
# timber relic Yeah, you can call 'GetComponentsInChildren' in your baker and get all child inf...

Thanks for this, it makes sense. I'm still new to DOTS and ECS and not knowing all the possible approaches is what is hindering me. Maybe a little more assistance may help. For example, I have basic shape colliders attached as sub children GameObjects. The number of these basic shapes depend on the prefab and can vary for every prefab variation. When converting the GO prefab, here's what I'm thinking, please let me know if this is what you think is best:

  • I save the sub gameobject with the "visible aspects" (the meshes) as the entity prefab component
  • I go thru all children gameobjects with the basic shape colliders and save that as a buffer component storing position, rotation and scale (I don't know if I need to store anything else)
    -- this also means that I discard the components mesh renderer, mesh filter, mesh collider from the gameobject (or should I be saving the child gameobject so all of these components are converted to entities?)

during playtime/runtime, I instantiate the "visible aspect" which is the entity prefab that I carved out from the gameobject prefab that contains the meshes, etc.
I manually create the unity.physics shapes from the buffer component, enumerating thru each item
The instantiated prefab and the manually created physics are attached to the mouse and moves with the mouse and following the terrain height
When ready, pressing 'enter' will place the visible prefab at the terrain location, but destroys all the colliders manually created

Is this in line with what you had in mind as a solution for what I'm trying to do?

#

Here's a sample of a 'small' prefab