Entity doesn't follow Injected GameObject

I use “CopyTransformFromGameObject” and “Convert and Inject” components. I have a system in which enemies chase this entity and it works fine. But when I try to track the collision with other objects with this entity, it turns out that it is in place, and not moving behind the object.

In other cases, if one object needs to follow another, I set Translation and Rotation from localToWorld.

Questions:

  1. Why are 2 entities created? Why does one move and the other stand still?
  2. How to make one entity follow another (if they are created from one GameObject)?
  3. Do I need to synchronize 2 entities in one game object to create another object separately with a separate tag, convert it to entity with “Convert and Destroy” and make it chase the first object?
  4. Is there a shorter way to synchronize the entity and game object?
1 Like

If anyone is still interested. I use localtoworld component and then do this in each frame:

EntityManager.SetComponentData(entity, new Translation { Value = localToWorld.Position });
EntityManager.SetComponentData(entity, new Rotation { Value = new quaternion(localToWorld.Value) });

Position works, but rotation works a little wrong. There is also a lag, this is noticeable if you move a followed GameObject very quickly. Therefore, the issue of following the entity of the Game Object remains relevant.

2 Likes

So is it possible to make this for a lot of entities? What I wrote above cannot be done for a large number of entities.