First off, no idea if this could help anybody, but I definitely wanted to write it down as solving my issues was quite a ride. Been deviating more than before starting with this tutorial.
general info:
For the animations I originally had 3 different animations with 3 different controllers for coming from the top, left or right depending on the position’s x value. Depending on x I’d assign the correct controller at runtime while the spawner used to store all my controllers in an array to load said controller from.
(I’m following all tutorials on Unity 5 btw)
Anyway, in order now:
First time I noticed something was wrong ->
I couldn’t build to WebGL, in fact, I couldn’t build anything at all.
All I got was a standard Windows error sound and a super unhelpful “there’s something wrong with your scripts” type message when I clicked on the build button. VS didn’t show me any errors in those scripts though (spoilers, indeed there weren’t any from it’s perspective).
Through googling I then found out about the Editor Log. Looking through there I finally got some directions on where these script errors originated.
new problem -> my scripts used to directly work with UnityEditor.Animation classes
As I’ve found out through more googling, anything that uses “using UnityEditor” (which I needed to store the animation controllers) is only working in the editor preview but won’t be able to be built unless the scripts are placed inside the special folder named “Editor”. So I tried that…
next up -> the scripts I just put in the new folder were suddenly unknown to the rest of my scripts. Turns out “Editor” folders are compiled last or something like that so all my normal scripts had no chance of knowing of their existence and were now throwing errors instead.
hacked solution -> instead of storing the controllers in my enemySpawner I used another special folder, the “Resources” folder. With that I could set the correct controller at runtime just as planned and all worked fine. Only thing bothering me now was that whenever you ask the internet “When do you use the resources folder?” the answer is: “You don’t.”
But I just had gotten another idea and realized how stupid I was for not seeing this ealier.
final solution for me -> delete the animation controllers, 1 is enough
Instead of having 3 seperate controllers for the 3 animations, I just put them all into 1 controller and played them depending on an int-parameter defined there. Now an enemy checks on Awake where it’s x position is -> sets the animator controller’s value then accordingly and in turn plays the correct entry animation.
Was quite an unexpected hassle, at least it’s working now :3