Hi, everyone! I have a prefab contaning a regular Animator for Sprite Renderer. I want to be capable of set the new states for the animation in certains moment, pretty basic in regular Unity.
However, I am using ECS. Animators aren’t converting to ComponentData. So, I use Animator as companion components (my baker adding to entity using AddComponentObject and my System get it over GetComponentObject).
The animator comes up, but none of the method works, such as SetBool. None error happens too.
I read a couple of posts on internet and none of them works. Moreover, it seems all written about have at least 3 years old… According to ChatGPT, Unity haven’t ported Animation to ECS so far (I don’t know if it’s true).
Can someone help me?
Some code to support you to support me:
My Baker
class CurveBaker : Baker<Curve>
{
public override void Bake(Curve authoring)
{
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new CurveComponent
{
totalCircleAngle = authoring.totalCircleAngle,
startRotationFrom = authoring.startRotationFrom,
trackSense = authoring.trackSense,
spentRotation = 0,
});
AddComponentObject(entity, authoring.GetComponent<Animator>());
}
}
Instantiate the entity from prefab through SystemBase:
Entity prefab = this.GetPrefab(newPiece, _prefabs);
Entity instantiatedEntity = EntityManager.Instantiate(prefab);
Interacting with animation in some place of SystemBase.OnUpdate
var animator = EntityManager.GetComponentObject<Animator>(entity);
animator.SetBool("gotoHalf2", true);