Sign in to follow this  
Relfos

Some AI and collision questions

Recommended Posts

In my game, the player can select a character with the mouse, and click on the map to move. Originally, the characters just moved in a straight line from point A to B, but now I added objects to the map, and of course, they should not be able to move through them.

So my solution was, to spawn around the map some invisible points, I called 'AI nodes'. Those are arranjed on a grid, and at the loading of the map, I test which ones can connect to the neighbours, and add those connections, as you can in the image below.



Then, when the player tries to move the character, I implemented a funcion that find a path using A* (the ordered list of nodes the character should use to move from A to B).

The problems:

1 - The path they follow does not look very natural, even increasing the AI node grid resolution does not improve this. Probably the characters should only use the node list as a rough path, instead of moving from node to node like robots.

2 - Even though this solves not going through solid objects, it does not solve going through other characters. Characters can not be included in the A* pathfinding because they are not static, they can be in one place when the path is calculated, and some seconds later, be in a different spot, so what to do?

3 - I am having a problem how to do the collision detection for this. Right now I raycast from one node to another and check for collisions with objects. However, this is far from perfect, some objects can have holes (like on that picture) and so, sometimes the ray hits it, and sometime it misses.

If you know any tips about one of those three topics, tell me, thank you!

Share this post


Link to post
Share on other sites
Well, problem 3 is solved, now I do all the collision login in 2D.
Problem 2 changed, now I calculate collisions between characters.
If the two of them are moving, all works ok. But if one is moving and the other is stopped, and the moving one bumps into the other, it is a problem, since it cannot move anymore. Probably needs some kind of steering behavior, hmmm, not sure how to implement that.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
Quote:
the moving one bumps into the other, it is a problem, since it cannot move anymore

Just implement your pathfinding algorithm again, but eliminating the blocked path as a solution.


Hmm, but the problem is, the path finding algorithm does not know anything about characters, just path nodes connected to each other.
The character collision is done after calculating the path, and when the character is moving.
I found this link, I'll try to implement 'obstacle avoidance' like described there.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this