im very new to unity and cant find an answer on google. I have an orb sent by an enemy that slows the player if it hits them. what I cant figure out is if a second orb hits the player I want it to slow them even longer. currently it just runs the normal slow duration and ends. also for some reason even after the slow ends the player is immune to being slowed again for a second or two.
sorry if this is the wrong place to ask, its my first time posting here. if theres a correct place to ask questions please point me there ty!
heres my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerSlowed : MonoBehaviour
{
public bool isSlowed = false;
private float defSpeed;
private void Start()
{
defSpeed = GetComponent<PlayerController>().moveSpeed;
}
void Update()
{
if (isSlowed)
{
GetComponent<PlayerController>().moveSpeed = 2.5f;
StartCoroutine(SlowTimer());
}
}
IEnumerator SlowTimer()
{
yield return new WaitForSeconds(2.5f);
GetComponent<PlayerController>().moveSpeed = defSpeed;
isSlowed = false;
}
}