Hey there,
I’m using an archer as my defender (instead of the cactus) so I wanted to implement a delay between when the projectile is instantiated and when it is fired from the arrow.
after some messing around, i finally got a coroutine that does fire arrows at the right time (previously my arrows were moving and then pausing when a new arrow was instantiated).
My issue is that the fired arrow will slow down once a new arrow is instantiated and then it will speed up again.
Does anyone have any ideas for a fix?
I’ve included video of what is happening, screenshots of my relevant code.
Archer script:
[SerializeField] GameObject bow;
[SerializeField] GameObject arrow;
public void LoadArrow()
{
Instantiate(arrow, bow.transform.position, Quarternion.identity)
Projectile script:
[SerializeField] float arrowLoadTime = 1f;
[SerializeField] float arrowSpeed = 1f;
private void Start()
{
archer = FindObjectOfType<Archer>();
}
private void Shoot()
{
StartCoroutine(ArrowFly());
}
IEnumerator ArrowFly()
{
while (true)
{
yield return new WaitForSeconds(arrowLoadTime);
transform.Translate(arrowSpeed *
Time.deltaTime. * Vector2.right);
}