Rotation and Scaling why?

I have this code:

The target is a object with the tag named enemy

if (target)
        {
            if(target.gameObject.tag == "enemy")
            {
                // Rotate object to the target
                Vector3 relativePos = target.position - transform.position;
                Quaternion rotation = Quaternion.LookRotation (relativePos);
                ball.transform.rotation = rotation;
            }
           
            if(Time.time >= nextFireTime    )
            {
                FireProjectile();
            }
        }

I dont know why but the code was ment to just rotate the object, see the result in the video:

Because the parent object has a scale

This is probably because you have a non-uniform scale on some parent to the turret.

edit: What hpjohn said ^^

So how do i fix it?

Put your rotating object under a parent (or hierarchy) that isn’t scaled.

Here is the hierarchy of the object

2049983--133291--hier.png

I assume “ball” is the object rotating?
You need to set the scale of Turret and base to (1, 1, 1)
If base needs to be scaled, you will have to put ball directly under Turret, not as a child to base.

ThermalFusion, thanks that help! love to you!

1 Like