Hello guys, I worked on a peronal Event system to make my player interact with other npcs on map. The Event system implements a system of variables and switches to trigger the storyline. Everything works, everything is done, the various commands will be called from a list of string. For each string in this list, the Interpreter will call a specific function during the game (Moving an object, show a dialog and so on). The problem, dear me, is the Interpreter itself. I want this "reader" to call the various commands one by one. I tried with a coroutine but nothing, or maybe I scripted bad. How can I call these methods, these commands in sequence, waiting for the previous one to be over? Thank you very much!
It sounds like you're on the right track. Make each function a coroutine. In your main coroutine, yield until the function coroutine is done. For example, roughly: Code (csharp): IEnumerator Interpret(List<string> commands) { foreach (var command in commands) { yield return StartCommandCoroutine(command); } } IEnumerator StartCommandCoroutine(string command) { if (string.StartsWith("MoveObject")) { return StartCoroutine(MoveObjectCoroutine(...)); } else if (string.StartsWith("ShowDialog")) { return StartCoroutine(ShowDialogCoroutine(...)); } // etc. } Consider it pseudocode above, just to get the idea across. I assume you'll have to do extra parsing to get the details for each command, so I glossed over StartCommandCoroutine.