I’ve got a unit that turns to keep facing its target as long as the target is in sight and in range. While those conditions are being met, the unit fires projectiles at the target. I haven’t tweaked the actual firing process with timing etc, but I have set the position of instantiation at Vector3.forward to avoid collision with the firing unit. The problem I’m having atm is that the unit turns, but theprojectiles instantiate in the same place (the original face forward of the unit). When the unit does an about face to see its target, the projectiles instantiate behind it. Any ideas on getting the spawn position of the projectiles to rotate with the unit?
protected void RangedAttack(Transform target)
{
GameObject missile = (GameObject)Instantiate (projectile, transform.localPosition+Vector3.forward, transform.localRotation);
missile.transform.position = Vector3.MoveTowards(transform.localPosition+Vector3.forward, target.position, Time.deltaTime * 20);
}