A* Pathfinding Project

Ignore obstacle at certain moment doubt


#1

Hi!

First of all, the A* Pathfinding asset is awesome.

Secondly, I have characters in 2d that walks around (when clicked and then destination clicked). It searches for the best route from where the character is to where the mouse has clicked. But one of the obstacles is also a “hideable” place, so that if you click on the obstacle, the character enters it (what is an obstacle is actually “enterable”).

Is there a way for it to work that way? I have browsed the documentation but I have not found anything. Also I did not want to change the obstacle’s layer because even though it is enterable at that moment for a specific character, it is not for other characters and they should avoid it as an obstacle.

Right now, if I click the obstacle, it just walks to the upper point of the obstacle.

I appreciate any help!


#2

Hi there, I’m new with this asset too but since you didn’t get any answer Ill try to help you…

How is your current scene set up? are you using Agents? because using agents you can tell each of them with layers are “enterable” and which not… I think that way you could tell certain characters that layer is hidden or not.

Here is the component and how you set it up. In my case every agent has the same layer colliders but you could modify that whenever you create them.

See ya! :slight_smile:


#3

Hi!

thanks for your reply! I am using the free version right now so I don’t think I can use it, but knowing that there is an option in the pro version I’ll upgrade it in the future.

Currently I solved it with some spaguetti code.

Appreciate your help!


#4

Tags might also work for you.
Adding small zones to the hideable places with higher penalties.

or if only certain agents can enter the hiding spot, make it Not Traversable for other agents


#5

Hi

So it sounds like you want the agent to just navigate to the hiding place’s entrance and then use some special code to hide the character.
This sounds like it should be handled completely separately from the pathfinding part. You should detect when the player clicks on a hiding place and in that case set the destination of the agent to the entrance instead of the center point of the object (or where the mouse is, not sure what you do right now). Then when the agent reaches the destination (check ai.reachedDestination) then use some custom code to hide the character.


#7

Hi!

this was my first idea, but in my code my character actually enters the place (you can see the character from the outside).

Great project. Will definitely support it in the future.