Will do. I have my fingers crossed that only minor changes will be needed.
I would very much so appreciate it
I am loving this.
Ahhh sweet, time to play the waiting game. We're going to try and prototype a mobile game in the meantime
Fun times ahead!
I'll say I did enjoy working on Infinite Cosmos. It's a different beast, for sure.
-
I'd like to get on the topic of AI and Pathfinding, if anyone is interested. I'm curious to hear anyone's approaches on 2D platformer specific pathfinding. I just started work on getting what is probably the most problematic AI pathfinding in a 2D game - an object that can move through the environment just as well as the player, given free reign and accounts for geometry changes. I spent about a good 6 hours today toying with one method, which I am finding it to be far more work than two other options I am considering.
Method 1: Complete AI Control
No nodes, no triggers. This was the method I worked on today. The simple is the entity can "see" obstacles, objects, platforms and various other collision objects within it's immediate vicinity. It knows if there is a collision object above it, below it, to the sides, etc. It also knows the player's exact position on the map and can "follow" the player. Not by pathing the player has made, but by direction.
I found this method of complete AI freedom insanely difficult as I've never attempted it before. My result after about 6 hours was an entity that can follow me through some simple platforms up and down, chase me over obstacles and not chase me past walls that were too high for the entity to jump over. The following GIF shows this freestyle AI in action, albeit limited since it has no combat instructions:
(lowered GIF framerate for file size)
Self-contained recognition, no nodes, no triggers. You will see there is no "path" to find for the enemy and it does not follow the player's line of travel. It just looks to always engage the player and avoids obstacles or uses them to reach the player.
It's still very crude as I haven't written much of the actual "follow" for the AI yet - I figured the hardest part was getting the entity to recognize when he could jump, when he should jump and when he shouldn't jump to follow the player. Noting where the player is, the player's direction, when the player is out of reach for that enemy's combat AI, etc. This way the AI knows to jump gaps instead of jumping down, jump up through gaps, etc.
This method can work out well, but it does require an extremely high polling rate and a METRIC TON of checks in every conceivable direction for distance and it has to recognize objects as platforms, obstacles and walls all on a SINGLE check against one layer. I don't like abusing layers and using tags are a no-no since I reserve tags for special platforms and objects so the player's physics knows how to act. So I resolved to not only checking things like walls as a collision object ahead of the enemy, but the height of the collision, as well. It's unruly to write entire AI like this and there's a lot more I can do to clean up and improve this method but it ultimately becomes to difficult for someone of my coding speed and puts too much control in the hands of AI.
Mehtod 2: A*
This is probably the most popular method to find a path as it relies on the "shortest possible" line, curve, or angle between two points. It uses values to graph each "move" the object makes and finds the path with the lowest sum available to create the shortest distance to traverse. This method works insanely well in your typical top-down game but can be problematic in a 2D sidescrolling platformer. The problem lies not in the path but the obstructions in that path. Jumps, wall jumps, moving platforms, etc. This is much more difficult to weave in this type of traversal with A*, I believe. This I probably will not attempt.
Method 3: Nodes
This method seems to be the simplest and I feel can work well when coupled with the first method to help simplify the decision making process of the AI controlled entity. With a node system we can let the AI know exactly what is around AI when it collides with it. So for edges of objects we can let the AI know that it has approached and edge of a platform and run it's "You're at an edge" AI function to see what the AI should do next - continue down, jump, turn around, stop, etc. These can be fleshed out further based on the state the AI is currently in - follow, flee, combat, etc. "Player jumping up between walls? Well this node tells me if the player is moving above me I can also wall jump and I know exactly where my first point of contact needs to be!" That sort of thing.
The only difficult part is making all of these different types of nodes and setting their instructions - as you will more than likely have a handful along with a few dozen one-offs. The good part is that it can take care of a lot of heavy lifting your AI needs to do in order to traverse the environment because it no longer needs to "see" the environment, it just needs to react to these nodes based on state. The other good part is that as you create geometry - you can set the most commonly used nodes as prefab items on arbitrary platforms, ground, falls, etc.
I pretty much dislike the first method due to it's insanity to make something so self contained with the enormous amount of checks that need to be done and the ability to freely recognize the environment without nodes or a navmesh. Plus I'm quite sure my skills are not up to the task, sadly. Given a few weeks I can probably nail that method down, but I would ultimately like something that is more flexible as the first method would literally have to tie in with combat routines which are particular to only 1 type of enemy. So reusing that system would mean an overhaul almost every time.
I believe my best method is to go with the 3rd option. A* in method 2 is really nice, but I feel I would be diving into a headache trying to write an A* system for 2D platforming.
What about everyone else? What would you think would be the most flexible from creation and implementation?