Putting objects inside an empty GameObject changes the original position.

So i’m new to unity, and i’m trying some things before going for a Tower Defense game.

I checked the LookAt function with a camera pointing a simple object(like cubes), and it works fine. I also tried with simple objects facing other simple objects.

Then, i make a “Enemy” which is composed by cubes and spheres, and a “Tower” which is made from cylinders and spheres. The tower is divided on two parts: base and top, and top part should face the Enemy.

Here is the “fail”. When i use the LookAt function, if i move the Enemy, the tower starts doing an orbit-like move too, instead just facing the enemy. Then i try the same thing with a simple object facing the enemy, and it works, but i observe that the object looks to a point which is different to the actual position of the enemy. Like if enemy has a “real” position and a “fake” position.

I confirmed this by adding a sphere collider to enemy, and -what a surprise- it appears just at the point i mentioned.

Why this happens?

When you parent one object to another, the transform of the child becomes relative to the parent. The transform of the child in the inspector is local transform. A child object will also move with the parent.

In hierarchy, a gameobject dropped onto another gameobject becomes a child of that object.