Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Yanifska on October 19, 2013, 02:41:32 PM

Title: Unity Pathfinding questions
Post by: Yanifska on October 19, 2013, 02:41:32 PM
Hi everyone,
I have been playing with the unity pathfinding system those last days.
and I have to say that I quite like it and the playmaker actions helped a lot.
A few questions remains for me though.

I understand  that the SetDestination and SetDestinationAsGameObject don't send a Finished event, is that right ? I had to use the GetRemainingDistance action with every frame enabled to be able to get out of the state. It is quite weird in my opinion. Why an action would not send a Finished event ?
Also there is the threshold. Why is it needed ?  Is it ok to have it at 0 ?

I have a situation where I place a target randomly and some time the state get stuck. I suspect it is because the target is too close to the Agent and won't trigger the SetDestination.

I would love some insights about these basic actions, the manual seems a bit empty on this subject

Thank you,
Title: Re: Unity Pathfinding questions
Post by: Yanifska on October 20, 2013, 11:52:07 AM
Hey guys,
I am bumping this as I can't find a solution.
It is a basic idle / wander state for an enemy AI.
My fsm has a first state in which it choose a random location in an circular area ( I found a custom action on the forum). Then it set the position of a target to this location, then SetDestination As GameObject to the target. Finally wait a random time.
It works but sometime it get stuck on the SetDestinationAsGameObject.

Maybe it is related  to the threshold. As it seems the SetDestination doesn't send a finished event, I am not even sure it moves.

Does anyone have an idea on what could be going on ? any strategies on tracking down this bug in my fsm?

Thanks !
Title: Re: Unity Pathfinding questions
Post by: CareLevelZero on October 20, 2013, 01:01:20 PM
When it hangs on that action, is the object still moving / did it move at all?  Or is it hanging before it can finish setting the destination?

If it works sometimes, but fails others, I'm wondering if it does something like grab a random location that's too close to the current location.  If it's managed to update the target location before the hang then maybe you can check that value and identify a correlation between the times that it fails.
Title: Re: Unity Pathfinding questions
Post by: jeanfabre on October 20, 2013, 11:03:15 PM
I think I recall I had to implement my own triggers to securly check that the agent went to the rigth spot ( or check manually for the remaining distance),

 Have you studied the samples provided in playmaker? does that work there for you?

I have added this to the trello todos :)
If you want to have access to this and vote you favorite plugins to support, simply pm with your email to be part of this board.


Title: Re: Unity Pathfinding questions
Post by: Yanifska on October 21, 2013, 12:19:52 AM
Hi all and thank you for your comments,

I finally stumbled on the demo example and could study the setup in it.
Too bad these files aren't exposed for better visibility, would have saved me some head ache, I didnt .

I updated accordingly part of my setup and used SetDestination instead of SetDestinationAsGaame object. And I have the GetRemainaingDistance in a separate state. it seems to work better, I will run more test.

@Jean, I thought about having one more FSM for setting / checking the destination. For now I have already 2 FSMs per enemy, I would like to keep it that way : limited and optimized. I will see in the future If I really have to I will try a setup like you suggested.

The agent stop moving completely. My understanding is that it grab a location too close, that's why I implemented a distance check but it didn't help.

Thank you anyway for your feedback !
See you
Title: Re: Unity Pathfinding questions
Post by: Yanifska on October 29, 2013, 01:55:50 PM
Hi Jean,

I still had some issues with agent getting stucked, so I allowed myself to go through the Get Agent Remaining Distance action, and I changed the line :
if (_agent.remainingDistance==0 && arrivedEvent!=null){

if (_agent.remainingDistance<=1.5 && arrivedEvent!=null){

and it fixed my problem, it seems for now, I will run more test.
I suggest you add a threshold option that would allow more tolerance for the Arrived Event in relation to the agent Stopping Distance.
Does that make sens ?
Title: Re: Unity Pathfinding questions
Post by: jeanfabre on October 29, 2013, 10:56:16 PM

 Good point, Added to the list of todos for the trello task.