-------- OUTDATED VERSION SCROLL DOWN TO UPDATE 1 5/14/2022 ----------
Hi, I'm starting to make actions for some of the things that I use call method or get property for.
One of them is for Unity's advanced Navmesh extensions:
https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.htmlThis action just runs the build command on NavMeshSurface so you can change your navmesh's build when you want in-game. You would have to change the actual layout with other techniques like changing object's layers, or using modifier volumes.
Also let me know if there's any issue, first time I tried making a PM custom action!
-------- OUTDATED VERSION SCROLL DOWN TO UPDATE 1 5/14/2022 ----------
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.NavMesh)]
[Tooltip("Activates rebuilding the nav mesh on a surface in real-time. Requires the extra Unity extensions for Nav Mesh. \n" +
"https://github.com/Unity-Technologies/NavMeshComponents")]
public class BuildNavMesh : FsmStateAction
{
[CheckForComponent(typeof(UnityEngine.AI.NavMeshSurface))]
[RequiredField]
public FsmGameObject navMeshSurface;
private GameObject go;
private UnityEngine.AI.NavMeshSurface _surface;
private void GetSurface()
{
if (navMeshSurface == null)
{
return;
}
go = navMeshSurface.Value;
_surface = go.GetComponent<UnityEngine.AI.NavMeshSurface>();
}
public override void OnEnter()
{
GetSurface();
_surface.BuildNavMesh();
Finish();
}
public override void Reset()
{
navMeshSurface = null;
}
}
}