How can I change the point of an enemy which a turret(ai) shoots.

I have turrets within my tower defence game which automatically find their target and fire projectiles, a bullet for the standard turret, a missile for the missile launcher and a laser for the laser turret. The problem I am having however is that these projectiles are hitting the feet of the enemies due to the fact that it is aiming for the enemies positions and the Y of the enemies is 0.5 so that it is just on top of the floor. How can I make it so that the turrets aim higher and hit the centre of the enemy. Thank you if you can help, as the turrets shooting the feet of the enemy can be a bit visually ugly.

This is the code responsible for the way turrets lock onto targets.

 void LockOnTarget()
         {
             Vector3 dir = target.position - transform.position;
             Quaternion lookRotation = Quaternion.LookRotation(dir);
             Vector3 rotation = Quaternion.Lerp(partToRotate.rotation, lookRotation, Time.deltaTime * turnSpeed).eulerAngles;
             partToRotate.rotation = Quaternion.Euler(0f, rotation.y, 0f);
         }

Add an offset to the y coord so instead of using “rotation.y” use “(rotation.y) + [offset value]”

I have to look into this myself (it’s in the Unity documentation), but you can target the specific transform of ANY part of the mesh or the ‘skeleton’. Sami’s advice is a good quick fix, but you could also do (pseudo-code):

TARGET = MODEL_WIDTH/2, MODEL_HEIGHT/2, MODEL_DEPTH/2

…to set the target point at the exact center of the target no matter what size it is.

I had to do a similar setup for my 3D space combat game in DevC++, for targeting the different parts of the enemy ships (engines, weapons, shields, etc). Now I am working on that for a superhero MMORPG in Unity.