//calculate the point in space to fire a shot at
private void CalculateAimPosition(Transform target)
{
//look at the enemy
Quaternion diffRotation = Quaternion.LookRotation(transform.position - target.position, Vector3.up);
turretBall.rotation = Quaternion.RotateTowards(transform.rotation, diffRotation, Time.deltaTime * 2000);
turretBall.eulerAngles = new Vector3(0, 0, turretBall.eulerAngles.z);
}
I ripped the code from somewhere else. Quaternions are incomprehensible. I have a 2D sprite turret that should face towards an enemy target. If the enemy is at a position in the positive range of the x axis it works no problem. However if the enemy is below zero on the x axis, the turret fires in the exact opposite direction. Any ideas?
EDIT: Actually the x and y axes are always flipped to what they should be, and turret is just firing sort of close sometimes and nowhere near other times? Ugh.