Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Neolink on September 16, 2017, 02:44:44 PM

Title: Making a BuildNavMesh custom action.
Post by: Neolink on September 16, 2017, 02:44:44 PM
The current Unity Navigation component on github allows for rebuilding the navmesh at runtime, it works fantastic with the example projects and works in my project too if I use the script they provided, the problem is that the script they provided triggers a navmesh rebuild only when "Fire1" is pressed, I want it as an action that I can get my FSM's to trigger when I need it, in my case, it is when a building is created. As far as I can tell there is not a Playmaker action yet supporting any of the new Unity Navigation component features.

I've tried copy and pasting bits of the script into a custom FSM but I just get errors or nothing happens, I don't know how to code at all, so I am not having much luck!

The BuildNavMesh script provided by unity is:

Code: [Select]
[DefaultExecutionOrder(-100)]
public class NavMeshBaker : MonoBehaviour
{
NavMeshSurface surface;


void Start()
{
surface = GetComponent<NavMeshSurface> ();
surface.BuildNavMesh ();
}

void Update()
{
if (Input.GetButtonDown ("Fire1"))
surface.BuildNavMesh ();
else if (Input.GetButtonDown ("Fire2"))
surface.RemoveData ();
}
}

If anyone could help me turn this into a simple action which just activates the BuildNavMesh and then "finished" the action, it would be of great help!

Thanks!
Title: Re: Making a BuildNavMesh custom action.
Post by: Deek on September 16, 2017, 04:47:32 PM
That should do it (see attachment).
I haven't tried it (because I didn't need to work with NavMeshs yet and didn't want to download and setup all the necessary files from that GitHub just to test this action) but it should work.
Just specify the GameObject with the 'Nav Mesh Surface' component and you're good to go.

If there is something not working or if you wan't other behaviour/additional features, just let me know.
Title: Re: Making a BuildNavMesh custom action.
Post by: Neolink on September 16, 2017, 05:19:07 PM
Thanks a lot, it seems to work just fine :) I'd recommend this to go on the Ecosystem, I am sure many other people would find having a dynamic navmesh useful!

Title: Re: Making a BuildNavMesh custom action.
Post by: jeanfabre on September 18, 2017, 02:44:25 AM
Hi,

 ok, this is weird, I can't find any documentation on this, which version of Unity are you using?

Bye,

 Jean
Title: Re: Making a BuildNavMesh custom action.
Post by: Neolink on September 18, 2017, 04:48:45 AM
Hi jean,

Thanks for all of your hard work with playmaker! I am using Unity 5.6.3f1.

The documentation and components are here https://github.com/Unity-Technologies/NavMeshComponents .

I don't know why this is not included with Unity, it is so much better than the default Navigation and it has been demo'ed by Unity at many offical gatherings and on official youtube, but it is hidden away on github! I would expect it to be at least on the asset store with the rest of the free official Unity stuff, but it is not.
Title: Re: Making a BuildNavMesh custom action.
Post by: jeanfabre on September 19, 2017, 02:40:40 AM
Hi,

 Cool, It's incredible how much stuff is going on... How can we keep up with all of this! :)

 I'll check with Eric or Djaydino to tackle this runtime navmesh feature and provide maybe a set of actions and proxies to work with this.


 Bye,

 Jean
Title: Re: Making a BuildNavMesh custom action.
Post by: tcmeric on September 20, 2017, 02:33:47 AM
Sure, I will look into this one and post the results  ;D
Title: Re: Making a BuildNavMesh custom action.
Post by: craigz on September 20, 2017, 02:13:22 PM
Wahoo! +1 to this ;)