NodeCanvas Forums › Support › Tick() broken for non-repeat graph without actions running over time › Reply To: Tick() broken for non-repeat graph without actions running over time
Hello again!
I updated to the latest version of NodeCanvas and the problem is back so I have to repeat my local hacky fix again, and figured I’d point out the issue once more in hope for an official fix.
Here’s how I’m using Node Canvas:
This used to work just fine when I initially created this setup, but after upgrading NodeCanvas a few months ago, it is no longer executing my BT each time I Tick() it, only once the first time.
In CanvasCore/Framework/Runtime/Graph/Graph.cs, I have to remove the check for isRunning == true
in the UpdateGraph function to make my BT work, as a graph that doesn’t start any longer-than-one-frame action will apparently only “run” for one frame, and so Tick() will not execute it past the 1st frame (where it actually starts and gets executed once).
You suggestion from a few months ago does not help, the graph still isn’t considered to be running after the initial frame it ran and completed on, so Tick() does nothing.
Repro steps:
– Create a new project
– Import NodeCanvas
– Create a new GameObject
– Add a Behaviour Tree Owner to that object & set it to not repeat and do nothing on Enable/Disable
– Create a bound BT for that owner that simply logs a variable value from the blackboard
– Create a MonoBehaviour on that same object that contains the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestScript : MonoBehaviour { public NodeCanvas.BehaviourTrees.BehaviourTreeOwner owner; // Use this for initialization void Start () { owner.StartBehaviour(); } // Update is called once per frame void Update () { owner.Tick(); } } |
What happens:
– The value of the blackboard variable is logged once
What I expect:
– The value of the blackboard variable is logged each frame
This would work:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// Use this for initialization void Start () { //nothing } // Update is called once per frame void Update () { owner.StartBehaviour(); owner.Tick(); owner.StopBehaviour(); } |
but means it won’t work for any graph that lasts more than one frame.
Could you look into this issue please, and either support that functionality again, or let me know of an alternative supported way to achieve that result?
I guess the old Tick() behavior was “start or update” and the new one is “update if running” which is causing my issues. I’d just like to be able to update NodeCanvas without having to reapply fixes each time to maintain the functionality of the NodeCanvas version I started my project with.
Thank you
EDIT:
I guess I was a bit caught up on making sure Tick() worked like it did before, I can do this I guess:
1 2 3 4 5 6 7 8 9 10 |
if( !owner.isRunning ) { owner.StartBehaviour(); } else { owner.Tick(); } |
Let me know if you see any issues with that approach, thank you