A 2D platform that uses MLAgents for AI
The idea to start this training environment comes from Immersive Limit's platformer challenge. Immersive Limit
Using reference from Hummingbird ML Tutorial I turned the basic HeroKnight.cs script into a HeroKnightAgent.cs. Compare HeroKnight.cs with HeroKnightAgent.cs to see the few changes that had to take place.
- The first issue I ran into during training was that after the agent moved left and right a few times, all of the sudden, the agent would be stuck jumping up and down and turning left and right, but not moving left-right.
After considering the .config file as a culprit, I realized that the bug was coded into the roll animation. The HeroKnight.cs script is a MonoBehaviour and it is able to link to an animation event. In this case, the last frame of the roll animation would call a funciton in HeroKnight.cs to set
m_rolling
to false, which would then allow left-right movement to take place. Yet because HeroKnight.cs became HeroKnightAgent.cs and theMonoBehaviour
becameAgent
, the animation event was unlinked, thus no longer called the said function to setm_rolling
to false. To fix this I removed all notions of rolling for now. - Training ... more info to come
Cinemachine 2.6.3 MLAgents 1.0.6 2D Tilemap Editor 1.0.0