A* Pathfinding Project

Astar path script scan isn't detecting my collisions correctly


#1

Hey,

Everyone so for I love this plugin if that is the correct term :). I have a bit of an issue with it and don’t know if this is the correct section to post this. Hopefully it’s alright :slight_smile:

I have a grid map setup for my game and the player is able to create roads. The roads have 2 Tilemaps. One is for colision of the road which in my case is always dirt and the road sprite which is walkable.

Here is the scan I get from the Astar Path. I have outlined with purple where are my colliders of the road which aren’t being detected. http://prntscr.com/qw3zaw

Thanks for all the help :slight_smile:


#2

Hi

Are the colliders included in the collision testing layer mask in the grid graph settings?


#3

Hey,

Yep I included them.


#4

Are you sure they are marked as colliders and not triggers?


#5

Yes they are exactly the same as my dirt tilemap.


#6

Do you think you could post a screenshot of your graph settings and the objects?


#7

Sure :slight_smile:

Here is a picture of my graph : http://prntscr.com/qwvbgu
Enemy : http://prntscr.com/qwvbwb
Road tilemap : http://prntscr.com/qwvct7


#8

Hi

The ‘Diameter’ for the collision setting is set to 0.3. That means it will only check in a small circle in the middle of the node for colliders (the width of the circle will be 30% of the node width). Set it to something closer to 1 for better results.
In the current beta there is a visualization of this value which helps to avoid these kinds of issues.


#9

I’ve tried that but then the whole tile becomes unavailable.


#10

It does look like your corridor is much more narrow than a single node.
You cannot have it both ways. In this case you want to avoid making the node unwalkable due to a narrow corridor, but in the other case you want to detect colliders near the edges of the node.
You can increase the resolution of the graph to be able to differentiate between finer features.


#11

I am not sure i understand what you mean. Could you explain please?


#12

In your last screenshot you show that the hole that was dug is pretty narrow. So the collider definitely overlaps the node. So it is reasonable that you’d want a smaller diameter for your collision testing.

However earlier you showed the colliders that you do want to detect. They are definitely further away from the center of the node than the edges of the hole in your last screenshot. So it’s hard to set the diameter to any value which works for both.


#13

Oh ok I understand. I’ve even tried creating two different grid graphs and check the collision for both but seperated. Did not work. Do you maybe have any suggestions on how I could achieve this or if there is any tutorial on it?

Thanks for all the help so far ! I really appreciate you taking the time :slight_smile:


#14

Hi

Well, your constraints are very inconsistent.
It is possible to do it with multiple graphs and some code, but I don’t see why you have to handle the different colliders that differently.

Am I correct in interpreting that you want the nodes touched by the purple colliders (here: https://prnt.sc/qw3zaw) to be made unwalkable?


#15

Hmm not sure how I would be able to do it with multiple graphs and code… :confused:

What is inside the purple is the collider which shouldn’t be passable. So no it isn’t ment to be walkable.


#16

But the purple collider only covers a very small part of the node?


#17

Yep example :


Top one is the walkable part and the bottom one isn’t walkable.


#18

I’d suggest that you put a collider there that covers the whole node in that case.


#19

Then the player won’t be able to walk on the road.


#20

But you just told me you wanted it to be unwalkable…