Can A* Pathing in AndEngine allow a sprite to determine "incorrect" paths and make "random" choices? - andengine

I am currently developing a Tower Defense game for the Android platform using the AndEngine. My enemies (animated sprite extended class) have hard coded pathing. I'd like to switch to something better where the enemies can determine for themselves where to go. I am using TMX maps. Please refer to the following map:
The 2 hexagonal tiles are spawn locations for the enemies. I have 2 questions abou A* Pathing.
At point A is it possible to make sure the enemy doesn't turn down the path towards the other spawn location?
From what I've been told A* Pathing looks for shortest distance, so is there a way to have the enemy randomly select which way to go at point B?
If A* Pathing is sufficient for these test cases, can you supply me a link to a tutorial/example? I haven't found much help through Google.
If A* Pathing can't do this, what are my other options?

In order to use A*, you need to know where the enemy is trying to get to. If you randomize the target locations of the enemies between the two exit points at the right, they should work correctly.

Related

Unity 2D: physics-based pathfinding package/library

I'm working on a small project where the goal is to defend yourself from mass enemy hordes in a 2d environment. The goal is to have the game be physics based, with enemies pushing against eachother to create a feeling of chaos.
Now I have a setup with enemies, a player and multiple obstacles all with a Rigidbody2D and 2D-colliders (mixed types, including polygon2D collider). Now I want to have the enemies chase the player. The obstacles however are polygon shaped rigidbodies, and thus are able to move.
So I want the "navigation" mesh of some sort to update on the fly, and calculate a navigation path for many entities.
Note: I don't know how many entities yet, but let's say ~100.
The things I tried to far:
Using the built-in NavMesh package from Unity. This package does not properly support the 2D configuration of Unity
Using the NavMeshPlus package. This implements a NavMeshSurface2D component to work with the 2D environment. I got this to work, but the NavMeshAgent component to steer the enemy does not use the force attribute of the rigidbody component, but rather just sets the speed or position of the transform. If someone knows how to use the NavMeshAgent or the NavMesh API in a way to get the target direction/speed via script, that would also be a solution
I tried the A* package. Which also works, but creates a very jagged line as it only can move in 8 directions (up,down,left,right and diagonals). It also cuts the corners of the obstacles, and does not take into account the size of the object (enemy) itself, so it hangs at the corners.
If anyone knows a good package/extension or the location of documentation of the NavMesh part, that would be great!
Thank you in advance.
So I got it to work and will share the solution I took:
Using the NavMeshPlus package, I created a navmesh.
Instead of using a NavMeshAgent, I configured an agent type in the navigation window with the right physical dimensions.
Next I added a script on the enemy to function as a custom NavMeshAgent.
Add a NavMeshSurface2D reference to the script (Serialized)
Using UnityEngine.AI, call NavMesh.CalculatePath(), with the AI.NavMeshQueryFilter. This has 2 components, the agent and area setters. Both of those I get from the NavMeshSurface2D reference.
Now you have the path the agent has to follow!
By the way, I'm also aware this could be done by a custom Agent inheriting the NavMeshAgent class, I'm also looking into that. Time will tell which one will have better performance.

Unity, how to make NavMesh Agents climb obstacles from any point around it?

So I'm working on a game where I want my AI to be able to smoothly climb obstacles from any point around the obstacle but I'm having a hard time trying to figure out how to do this. I know I can use off mesh links to have enemies go on to obstacles but the problem is that they all funnel from a single point and it looks very unnatural. Now I could make a bunch of off mesh links for each obstacle, but I have a lot of obstacles I want to be climbable and that's not very efficient.
Is there a good way to go about this that I can make all of my AI climb at any point around an obstacle? I'm currently using A* Pathfinding but this is kind of a must for my game so any ideas regardless of if A* can do it are welcome.

-Roblox- How would I make an AI path finding bot that only moves on certain objects?

So currently I am making a game which involves guests like Coaster Tycoon 2...
I already have my AI script finished but I want to implement some more code so it only moves on parts named lets just say "Path". How would I go about doing this???
Hi there I suggest maybe making it so the guests are can collide mode then make it so that the player can't collide with anything other than solid objects. So put invisible walls along the paths and make it so the guest can't walk through them but the player can. Then do it so the guest when he hits a wall turns a different direction. Then script it so the players can walk through them walls.
In the past, I've done this by using the A* pathfinding algorithm. You can modify the algorithm a bit so that the only nodes ever used are ones that fit your need (e.g. "Path" nodes). The ROBLOX Wiki has an A* page with a good implementation of the method.

What would be the best way to do pathfinding on a random object that rotates

I want to do pathfinding on a rotating "planet", similar like the enemies do in mario galaxy, except the planets are rotating. What would be the best way to do it? The planets come in different forms, and it is necessary that I place the waypoint with code. That is because I need to do it with code for my assignment and also I want to make an object pool of waypoints that get placed on the planet the player is currently on.
So is A* the best way to go? I was thinking about the technique I should use and I thought of placing every waypoint on a vertex of the model. But some models can get pretty high in vertices, so isn't that really heavy if I have that many waypoint and then use them for path finding?
Or is there a better way of doing it? I was thinking can't you do it based on the uv's of the planet? The only thing is that the uv's have cuts so how can I tell the enemy to also check the cuts of the uv's for a shorter path?
Best way to animate planets will be to download leanTween or some similar asset and make animation by curve path + rotation.

Questions on how to create a game similar to Pac-Man

I want to make a game that will be similar to Pac-Man from scratch. I don't want to use a games engine either, just plain old Xcode.
Basically the game would consist of a map that fits the screen, walls within the map, food, enemies and a player.
I just wanted to know what the best way forward would be. I plan on creating the map first, and then doing everything else after that. Where should I begin?
I plan on creating the map first
Keeping in mind that you'll probably want several maps, you might want to create a map editor first, which would let you place "wall" graphics and define the paths along which the player & ghosts are allowed to travel. If you define those paths with nodes at each intersection, the ghost AI becomes easy to solve with A* path finding. Your map editor can use the distance between intersections to calculate the "weight" of each path segment.