playMaker

Author Topic: Nav Mesh Draw Path  (Read 844 times)

SPACE GAMER

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
    • Portfolio
Nav Mesh Draw Path
« on: April 27, 2017, 09:42:59 PM »
Hi I'm not much of a programmer but I manage to get by with playmaker and its eco system. I was wondering if there is an action or a set of actions I could use to draw my nav agents  path on a baked terrain nav mesh (during gameplay). I pretty much want to show how far a player can travel and what route he will take with a line. If someone decides to create this action please add an option for a limit on the distance the line will render. I think it would be neat if someone could create this action or a tutorial for me and fellow playmaker users alike. If not could you point me in the right direction because there are no playmaker tutorials out there on this subject.

Thanks in advance for any help or knowledge on the subject.

skipadu

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: Nav Mesh Draw Path
« Reply #1 on: April 27, 2017, 09:59:43 PM »
Here is some answer that might help you to show the path:
http://answers.unity3d.com/questions/361810/draw-path-along-navmesh-agent-path.html

It's not using Playmaker, but maybe some experienced Playmaker user can help you with that.
And it seems to just have the ability to draw the path, so the "cost to move" function is needed to be done separately.


If you mean Walking Dead or other game that will show much it does cost to move to selected position / enough points to move there, like:
https://us.v-cdn.net/6025874/uploads/editor/e4/dp2jub2piw3a.png

For e.g player has 10 points to use, so the line is red then user points too far away as it take over 10 points. Then if it is under 10 points to move to selected location, the path is seen as green etc.

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Nav Mesh Draw Path
« Reply #2 on: April 27, 2017, 10:03:26 PM »
Right, so in my game I am also limiting movement depending on distance to the destination. The problem is that navmesh destination paths in real time dont work. They take can take a few frames or more to calculate, even on my i7.

Ie, if you want your mouse to be able to hover over any location and then draw the line, the path has to be calculated in real time (or there is no line showing the nav mesh destination path). Think jagged alliance. I havent tried the walking dead one, but it looks similar. Therefore it also cannot limit the destination in real time.

Its a pretty complex subject that I have been working with for a bit. I am actually planning to migrate over to A* pathfinding because they support continuous path calculations in essentially real time. I dont think navmesh is up to the job.

Games like xcom, jagged alliance, etc only exist on a few planes. They look 3d, but really there is typically only a few layers, which makes nav calculations faster and more lean. They also use a grid system and not a navmesh (which is something different). Unity does not have a grid system out of the box, you need to use a third party asset for it. Which means a lot of custom work.

I talked with the people at Apex path and they said MAYBE apex could handle it, maybe not (which is grid based). Aron over at A* was pretty sure it was possible with his system and gave me a bit more hope.


« Last Edit: April 27, 2017, 10:14:09 PM by tcmeric »

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Nav Mesh Draw Path
« Reply #3 on: April 27, 2017, 10:10:42 PM »
Just to be clear, the continuous update function of A* is only part of the 100$ pro version. Currently it doesnt have any playmaker actions that work with the current version (A* version 4). I might be adding some playmaker support for it myself, but havent decided yet. Its a pretty big project.

Anyways, if you want to chat about it, you can find me on our playmaker slack channel, which might easier than back and forth here, as I am working on it every few days. https://invite-playmaker-slack.herokuapp.com/

SPACE GAMER

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
    • Portfolio
Re: Nav Mesh Draw Path
« Reply #4 on: April 27, 2017, 10:54:12 PM »
skipadu: Thanks for the quick response but I had already checked that article out and couldn't figure out how to make that work for me with playmaker. Sorry. and yes what I need would look like that walking dead example you showed me.

tcmeric: I want to display this during gameplay but a slow load process does not sound bad in my scenario. I would expect some type of late load to the path as I move the mouse about the screen. I want to draw the path from player to mouse around obstacles as I move my mouse away from player. Then once out of modified range I want the line to stop at max distance but still show, or turn red when its too long. I pretty much want it to behave just like google maps when you move your destination marker. It updates the line every frame and even changes the distance and time of arrival. I would love to be able to mimic the distance and draw line functionality's in unity, but using Unity's metric system instead. Do you have or can you create an action for something like that?

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Nav Mesh Draw Path
« Reply #5 on: April 28, 2017, 01:00:18 AM »
I will post my reply here too, just in case others find this later. If it trys to calculate as you move your mouse around constantly, I am afraid that will create an overall slow down in your game, as it keeps trying to calculate many many paths. Every vector3 move would start the calculation on the next path, as the previous one was still in progress. Its a lot of paths. I am not sure how many concurrent paths nav mesh can handle.

 One possible solution is for the game to not calculate the path until your mouse stays still until X amount of time. That could limit the amount of path requests. That is something you could do with the logical of playmaker.

There is no one solution that will solve this movement issue unfortunately. It will take even in playmaker, a fairly complex bunch of FSM to re-create this game mechanic (overall, with movement, action points, etc).

This is my tutorial on point and click movement using navmesh. If you wanted to use navmesh for pathfinding, this would likely be how to setup the first part. https://www.youtube.com/watch?v=iM_5Ma7hSC4&t=135s

The second part would be to use agent destination distance actions to calculate the distance and then float compare to see if it is within the distance.

Third, you would need a line renderer type action (you need a custom action, nothing in playmaker for this), that would draw the line if within the distance, or change color or something.

Lastly, you would need to then block movement if the distance is too far.

« Last Edit: April 28, 2017, 02:18:56 AM by tcmeric »

SPACE GAMER

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
    • Portfolio
Re: Nav Mesh Draw Path
« Reply #6 on: April 28, 2017, 09:43:44 AM »
Thanks a lot man I was up all night looking for scripts and solutions to this problem the best thing I could think of was to add some type of graph to the terrain and plot the points through that (but object avoidance would become a problem for pathfinding)or just make some type of game object graph around player representing range. Its going to be turn based so there will be no actions going on besides some mild character idle animations. do you think you could send me a screenshot of how you would try to map this in playmaker and Ill try to take it from there if you don't mind.   

SPACE GAMER

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
    • Portfolio
Re: Nav Mesh Draw Path
« Reply #7 on: April 28, 2017, 09:46:30 AM »
also would you happen to have an idea of how google maps achieves this with almost no lag.

SPACE GAMER

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
    • Portfolio
Re: Nav Mesh Draw Path
« Reply #8 on: April 28, 2017, 09:49:57 AM »
my next attempt will consist of using some of these methods to try and achieve this.
http://www.binpress.com/tutorial/unity3d-ai-navmesh-navigation/119

SPACE GAMER

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
    • Portfolio
Re: Nav Mesh Draw Path
« Reply #9 on: April 28, 2017, 09:51:03 AM »
Manually creating a path section

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Nav Mesh Draw Path
« Reply #10 on: April 28, 2017, 10:05:38 AM »
Sorry, I dont have time to post a solution, but if you use the get agent destination action, you can get a float. Do a float check to see if it is in range. Repeat.

My tutorial pretty much covers all the first parts about getting things started.

Maybe space out the navmesh destination calculations. Only do them x per amount of seconds and only when holding the mouse still.