Hello hello everyone !
I’ve been looking around for solutions on how to add an Animator Component to an entity (I need this one for smoother homemade transitions) but found nothing quite clearer than “not implemented yet except in hybrid”.
I may have found a quick workaround :
entityManager.AddComponentObject(entity, animator);
But the component remains not found (I get a NullReferenceException), even though I’m in a ComponentSystem (and not an actual job), and made sure that the type is added to the archetype.
My test code is extremely simple, especially when cleaned of rotations and translations.
public class System_Mover : ComponentSystem
{
EntityQuery anim_group;
EntityManager entityManager;
protected override void OnCreate()
{
anim_group = GetEntityQuery(typeof(Animator));
entityManager = World.Active.EntityManager; // I'm seeing now this could be better, my bad
}
protected override void OnUpdate()
{
Entities.With(anim_group).ForEach((Entity entity, Animator anim, ref Translation translation) =>
{
// sparing you unrelated details [...]
if (anim)
{
anim.Play("walk"); // I know keys are faster but this is a test.
}
else
{
Debug.Log("Animator not found"); // Execution lands here, meaning anim is false
}
}
}
I’ve tried making a proxy IComponentData to no avail. I’ve actually tried several things and harassed Google to a point most of advertisement is talking about it.
I feel like I could learn hybrid instantiation to achieve this, by making a classic GameObject with only an Animator Component and convert it (I haven’t quite looked yet at the hybrid way and pure is actually fun and mind-bending, which I kinda like) but I feel it could be done better. Is my feeling true? If not, how to properly do this?
I’m asking this as a provisional solution, because my teammate doing animations does not dare working with Animator if ECS doesn’t support them. I’m guessing a proper support should arrive one day (when?).
Thank you in advance.
Xime.