- Home /
Question by
tremorwilson2001 · Feb 28, 2018 at 11:58 PM ·
aienemiesturrets
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.
Comment
Could you share the code with us? At least the relevant part?
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);
}