Some things would be much easier to do if I could just use a gameObject to represent “the view” of an entity.
Say I have an entity with a health component. When the health component gets low, I’d like a gameObject (ie the player object in this case) to do the “Hurt” animation instead of the normal “Idle” animation. It would be really nice if I could somehow just attach a ‘reference component’ to an entity and have a system just update the game object.
My first thought here is I could build a monobehaviour with a dictionary of entities and objects; then have that monobehaviour update the animation every frame.
My gut tells me I’m missing something and there is an intended way of doing this.
Anyone care to share some knowledge on this topic?
TL;DR Is there some kind of component that can hold references?
Or is there an obvious way to update a game object based on an entity.
EntityManager.AddComponentObject. Also class IComponentData is a thing. Granted, if you care about performance, you should not do this and instead describe why you need the GameObject so we can help you get rid of it.
Thank you so much friend, I had no idea that I could make a class version of IComponentData.
I understand that this approach can be ‘slow’, but most of the the game will be pure entities.
The reason I need a game object in this case is because I want some objects to be doing animations and sound(player characters and enemies).
The amount that this will amount to per level will most likely never exceed 100, so I think performance shouldn’t really be a concern.
The rest of the game, Ie objects that are not animated and don’t produce sounds will just remain pure entities.