Weird NullReferenceException when Executing Function (MP)

Forums 💬 NodeCanvas ⚙️ Support Weird NullReferenceException when Executing Function (MP)

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18770
    jonc
    Participant

      Hi,

      I’m using the latest version of both, Unity and NC and I’m having a little problem. I’m trying to execute a custom function (not an Action/Condition) which resides in a custom public class:

      Which results in this Exception:

      Object reference not set to an instance of an object
      at PFPAgent.MoveTo (Vector3 targetPosition, System.Action OnPathFinished) [0x0000d] in PFPAgent.cs:125
      at NodeCanvas.Framework.Internal.ReflectedAction
      2[UnityEngine.Vector3,System.Action].Call () [0x00000] in AssetsNodeCanvasFrameworkRuntimeReflectionWrappersReflectedAction.cs:47
      at NodeCanvas.Tasks.Actions.ExecuteFunction.OnExecute () [0x00073] in AssetsNodeCanvasTasksActionsScriptControlExecuteFunction.cs:94
      UnityEngine.Debug:LogError(Object)
      NodeCanvas.Tasks.Actions.ExecuteFunction:OnExecute() (at Assets/NodeCanvas/Tasks/Actions/ScriptControl/ExecuteFunction.cs:104)
      NodeCanvas.Framework.ActionTask:ExecuteAction(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Tasks/ActionTask.cs:113)
      NodeCanvas.BehaviourTrees.ActionNode:OnExecute(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/Nodes/Leafs/ActionNode.cs:37)
      NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Node.cs:242)
      NodeCanvas.Framework.Connection:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Connection.cs:175)
      NodeCanvas.BehaviourTrees.Sequencer:OnExecute(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/Nodes/Composites/Sequencer.cs:27)
      NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Node.cs:242)
      NodeCanvas.Framework.Connection:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Connection.cs:175)
      NodeCanvas.BehaviourTrees.Selector:OnExecute(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/Nodes/Composites/Selector.cs:27)
      NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Node.cs:242)
      NodeCanvas.Framework.Connection:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Connection.cs:175)
      NodeCanvas.BehaviourTrees.Filter:OnExecute(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/Nodes/Decorators/Filter.cs:46)
      NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Node.cs:242)
      NodeCanvas.Framework.Connection:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Connection.cs:175)
      NodeCanvas.BehaviourTrees.ConditionalEvaluator:OnExecute(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/Nodes/Decorators/ConditionalEvaluator.cs:50)
      NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Node.cs:242)
      NodeCanvas.Framework.Connection:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Connection.cs:175)
      NodeCanvas.BehaviourTrees.Selector:OnExecute(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/Nodes/Composites/Selector.cs:27)
      NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Node.cs:242)
      NodeCanvas.Framework.Connection:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Connection.cs:175)
      NodeCanvas.BehaviourTrees.Sequencer:OnExecute(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/Nodes/Composites/Sequencer.cs:27)
      NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Runtime/Graphs/Node.cs:242)
      NodeCanvas.BehaviourTrees.BehaviourTree:Tick(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/BehaviourTree.cs:75)
      NodeCanvas.BehaviourTrees.BehaviourTree:OnGraphUpdate() (at Assets/NodeCanvas/Modules/BehaviourCanvas/BehaviourTrees/BehaviourTree.cs:60)
      ParadoxNotion.Services.MonoManager:Update() (at Assets/NodeCanvas/Framework/_ParadoxNotion (shared)/Runtime/Services/MonoManager.cs:80)

      This error only appears if NC tries to call the ‘MoveTo’ function directly.

      If I call the function from inside a custom action like this:

      …then everything works fine.

      The only difference is, that I actually pass a System.Action as parameter, whereas the direct call passes ‘null’ and therefor never “officially” ends the NC action. I can live with this workaround but still, it’s a bit confusing. ^^

      #18772
      Gavalakis
      Keymaster

        Hello,

        It seems that PFAgent.cs #125 throws a null reference due to the System.Action callback being null?
        The thing is that NC can’t use parameters of delegate type, at least right now.
        I think in this specific case it would be easier and more convenient to use a custom action like you did 🙂

        #18771
        jonc
        Participant

          Yeah, that’s what I’ll keep doing then. Thanks! 🙂

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.