Bunny83 Expression Parser errors on some computers

I’m using a math expression parser made by @Bunny83 to create paths for enemies. I cannot find the version I’m using online (a friend got it from somewhere), so here’s a very similar one.

An issue arose when parsing sin(3*x)*0.5. There is no problem with this expression on my or a few others computers, however it breaks on some other PCs. I’ve even tried running the game on Wine and in a fresh VirtualBox Windows 10 but I can’t reproduce it.

The error is thrown from the script itself: "Reached unexpected end within the parsing tree". This happens when the Parse() function doesn’t return a function. I also tried the version I linked above and it throws NullReferenceException: Object reference not set to an instance of an object, because that version doesn’t do anything with its error variable.

The ones with the bug have the latest .NET Framework 4.8 as I do. I have other enemies that work with a simple -x path. I suspect there’s a compatibility issue with some C# code that runs when the script parses the sine function, multiplication, parenthesis or/and even just numbers. Other thing that I know is that enemies after this error stop spawning, but it’s probably because a static class calls the Parser.

My Unity version is 2021.1.21f1, scripting backend is Mono and Api Compatibility Level is .NET Standard 2.0. I can try to change the last 2, but as I said I can’t reproduce the bug myself so I would have to send builds to others.

Well, the parser uses the local system culture setting when parsing numbers. While theoretically that could be desired, it actually would break some other syntax rules the parser has. So in effect in the current form it only works on machines with a culture that uses a dot as decimal point. Keep in mind that half the world uses a comma instead of a dot.

The best fix would be to make all double.TryParse calls use the invariant culture. However as a quick fix it could work to set the culture globally for your application. I’m pretty sure that could be the root of your issue.