I have not used coroutines within unity yet however the API does have a comment. Note: Do not mix the two arguments. If a string is used as the argument in StartCoroutine, use the string in StopCoroutine. Similarly, use the IEnumerator in both StartCoroutine and StopCoroutine.
Can you post the code you use to start the coroutine.
It is because you need to declare SmoothMove outside the IEnumerator (Edit: I mean outside the MoveUnit function):
// declared outside the coroutine
private IEnumerator SmoothMove;
public void MoveUnit(Stack path, Tile arrival)
{
// set the coroutine
SmoothMove = smoothMove(path, arrival); //The variable has capital S
StartCoroutine(SmoothMove);
}
then from inside the coroutine
IEnumerator smoothMove(Stack path, Tile arrival)
{
// and now you can acces the variable since it exist in the current context
StopCoroutine(SmoothMove); //I’ve also tried with “SmoothMove”
}
You cannot acces variables that has not been declared in the current context.