This is a follow up project to my previous AI project. This one is not self taught unlike the other one. Press 1 to see debug variables and visuals. It should work with any level possible without wall jumping, because the platforming script it uses does not support it. Pressing 2 will put it in slow motion - good for watching the debug screen!
Feel free to use this in your own projects, but please give credit! Copy all sprites except the 'target' and 'platform' sprites, but both are required for it to work, although the replacement sprites only need to be named what it is named in the code. I couldn't get it to work with you being able to control the green square (I think the AI is too laggy) but you can still try! :) How it works: If you press 1 you will see there is a black line and 3 coloured areas around the AI. Each coloured area tells the AI where to move - the green one is jump, the blue one right etc. The black bar will point toward the target if it is not touching the platform, in which case it will try to point toward the target as much as possible without attempting to move into the ground. The ideal direction variable stores which direction the target is, displacement is how far the bar has to move to avoid the platform and the expected angle is the direction the AI moves in.