PlayMaker Unity

PlayMaker and NavMesh

Either I’m blind, or PlayMaker doesn’t come with an Action for the Unity NavMesh feature.

In either case, it’s only a few lines of code, which you can find below.

The only thing you may want to change, depending on how you’re using the action, is whether or not to include the  Finish() method in there. This will exit the state if you have the transition set up, and you may or may not want to do that.

Here is the code:

using System;
using System.Collections.Generic;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
    public class NavigateToPoint: FsmStateAction
        public FsmVector3 moveToPoint;

        public FsmOwnerDefault agent;
        private GameObject agentObject;

        private NavMeshAgent navAgent;

        public override void Reset()
            moveToPoint = null;

        public override void OnEnter()
            if (agent != null && moveToPoint != null)
                agentObject = Fsm.GetOwnerDefaultTarget(agent);
                navAgent = agentObject.GetComponent<NavMeshAgent>();
                if (navAgent != null)




Leave a Reply