So, despite Rick telling me to stick to the ‘Projectile.cs’ I decided to use 2 scripts to solve the issues:
In the Health.cs - when something dies - I delete the collider - seemed easy enough to make sure arrows would pass over dead bodies.
As for the Projectile.cs - My solution allows you to turn homing on and off per projectile, as well as allow non-homing arrows to miss - as well as changing the ‘last shot fired’ from a homing missile into a non-homing missile if the target dies - so it will also just continue shooting straight. See my code - could probably be refactored or condensed - but hey it worked!
[SerializeField] float speed = 1;
[SerializeField] bool isHoming = false;
Health target = null;
float damage = 0;
bool shotsFired = false;
void Update()
{
if (target == null) return;
if (isHoming)
{
transform.LookAt(GetAimLocation());
shotsFired = true;
if (target.IsDead())
{
isHoming = false;
}
}
else if (!shotsFired)
{
transform.LookAt(GetAimLocation());
shotsFired = true;
}
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}