I created simple model with “chassis” and “turret” attached at the top (as a child). I’m trying to aim the turret at the target. And it does not work (turret turns in wrong direction and angle). What am I doing wrong?
Vector3 enemyPos = enemy.transform.position;
enemyPos.y = transform.position.y; //target position is middle of chassis and I do not want to lower my aiming point
Vector3 fromTo = enemyPos - transform.position;
rotationToTheTarget = Quaternion.LookRotation(fromTo);
transform.rotation = rotationToTheTarget;