playMaker

Author Topic: NavMesh/NavMeshAgent  (Read 4508 times)

johnflesh

  • Playmaker Newbie
  • *
  • Posts: 10
NavMesh/NavMeshAgent
« on: August 23, 2015, 04:48:56 PM »
Hello,

I'm a long time playmaker user but an absolute beginner using NavMesh and NavMeshAgents, Pathing in Unity 5. I downloaded the additional NavMesh/Agent actions for Playmaker and have had some success but I'm somewhat at a breakpoint and can't seem to move past it. Also, I'm an artist who use Playmaker for minor scripting, I'm not a scripter/programmer by any means so please excuse my ignorance.

What I'd like to do is have an Agent move towards a goal, however the goal may or may not be blocked from that Agent. The Agent needs to make decisions dynamically based on that. If the goal is not blocked, move to goal. If the goal is blocked, find closest tag "breakable" and destroy it, continue on path to goal.

Ultimately, I can achieve the above, however, every Action I use to check if the path is clear always produces a True. I need it to see that the path is blocked and produce a False - or True if the path is not blocked.

I've tried 'NavMesh Calculate Path Between Game Objects' which produces a True stored value regardless of whether the Agent is blocked or not.

I've tried 'AgentSamplePathPosition' as well but it produces a False stored value regardless of whether the Agent is blocked or not.

I've also tried 'AgentRayCast' and it always produces a True regardless of whether the Agent can actually see the goal from it's start position.

Now this may simply be an oversight on my part with my novice/beginner understanding of how NavMesh/Agent work within Unity5. I have been doing a lot of reading on the U5 Manual and Reference and while I have learned a bundle and it has gotten me this far, I'm somewhat at a loss.

TLDR; What action helps to check if a path is blocked (or not) on a NavMesh between Agent and goal, and produces True/False depending on the result?

Thank you for any help. I've looked everywhere and see very little on NavMesh/NavMeshAgent with Playmaker in tutorials. Many of the downloaded .unitypackage files produces many errors as they are quite old.

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: NavMesh/NavMeshAgent
« Reply #1 on: August 23, 2015, 05:39:46 PM »
When you say the goal is blocked, you are actually carving the navmesh with the obstacle right?

johnflesh

  • Playmaker Newbie
  • *
  • Posts: 10
Re: NavMesh/NavMeshAgent
« Reply #2 on: August 23, 2015, 05:54:14 PM »
When you say the goal is blocked, you are actually carving the navmesh with the obstacle right?

Correct.

Attached is a screenshot of the testing environment.

The white walls are static.
The blue wall is Obstacle set to Carve.
The orange space is the Goal.

If I leave the blue wall there (as shown in the screenshot attachement), then start the game - the Agent will go to the Goal but hit the wall endlessly trying to get to the Goal.

If I move the blue wall out of that space, then start the game - the Agent will go to the Goal, avoiding the walls based on it's set Avoidance. Works perfectly.

What I'd like it to do is; if blue wall is there, see that the path to the Goal is blocked - then target blue wall (or Nearest Obstacle), destroy it, check path is not blocked and/or continue on path to Goal.

The concept is: users/players will be able to place "blue walls" into the scene to help protect the Goal. The Agent's job is to find a clear path to the goal - if not, make one by destroying "blue walls" or various Obstacle gameObjects.
« Last Edit: August 23, 2015, 06:02:05 PM by johnflesh »

johnflesh

  • Playmaker Newbie
  • *
  • Posts: 10
Re: NavMesh/NavMeshAgent
« Reply #3 on: August 23, 2015, 05:57:34 PM »
Here is the NavMesh showing, with the Obstacle moved to show that it is Carving properly.

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: NavMesh/NavMeshAgent
« Reply #4 on: August 24, 2015, 08:55:57 AM »
Have you tried the Get Agent Path Status action?
I believe the Path Partial event will fire if the path is blocked.

johnflesh

  • Playmaker Newbie
  • *
  • Posts: 10
Re: NavMesh/NavMeshAgent
« Reply #5 on: August 25, 2015, 01:11:35 PM »
I don't think I have, no. I will give that a try terri. Thank you!

If it can produce a partial result, that would be exactly what I need.

I spent the last 2 days trying to familiarize myself with the actions as well as the U5 reference.

Thanks again, will report back!

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: NavMesh/NavMeshAgent
« Reply #6 on: July 06, 2018, 09:22:36 PM »
Hey Johnflesh! :D

Just wanted to give a shout and see if you ever did come up with a good system for this? Currently I'm doing an agent-raycast, then getting the point and telling my unit to go there and look for an enemy within 'x' range OR a gate/door. All sorts of fringe issues, but working decently.

Just was curious if you'd been able to find a reliable/better way :D

-craigz