playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Neolink

Pages: [1]
1
Playmaker Help / Making a BuildNavMesh custom action.
« on: September 16, 2017, 11:44:44 AM »
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!

Pages: [1]