(Just in case: Unique Video Reference: 11_BH_UPC )
Nonetheless, I consider it overly complicated to have a second Coroutine just for moving the shadow…
Unless there is more to come to do in the Coroutine I would simply define the shadow’s instance as a class variable, and add its movement to the ProjectileCurveRoutine
.
As for the shadow being place below, that could just be configured in its prefab, or one could simply have some correction for it…
GameObject grapeShadow;
Vector3 shadowAdjust = new Vector3( 0, -0.3f, 0);
void Start()
{
grapeShadow = Instantiate(/* ... */);
StartCoroutine(ProjectileCurveRoutine(transform.position, playerPos));
}
private IEnumerator ProjectileCurveRoutine(Vector3 startPosition, Vector3 endPosition)
{
/* ... */
transform.position = Vector2.Lerp(startPosition, endPosition, linearT) + new Vector2(0f, height);
grapeShadow.transform.position = shadowAdjust + Vector2.Lerp(startPosition, endPosition, linearT);
/* ... */
Destroy(gameObject);
Destroy(grapeShadow);
}