Forums › 💬 NodeCanvas › ⚙️ Support › BT seems to get "stuck" until clicked on
Im currently using the latest version. Anyway I switched from behaviordesigner and Im running into a somewhat strange bug where using the behaviour trees, my ai characters it will get stuck on a custom node until I click the gameobject in the editor, where it resumes the action.
https://www.youtube.com/watch?v=VPwc1xvlf_Y&feature=youtu.be
another video(better quality but a little less clear when it happens)
http://youtu.be/iu4Y5QB5Y2o
ok video quality is way worse than I thought it would be: what happens npc’s shoot each other, the remaining surviving npcs should resume their patrol and break off from the pursue task but it just sticks on the pursue task unless I click them individually. Anyway this is reproducible, I can upload the whole project if necessary. How do I fix this?
the pursue task code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
using NodeCanvas.Framework; using ParadoxNotion.Design; using UnityEngine; namespace NodeCanvas.Tasks.Actions { [Category("Actor")] public class ActorPursue : ActionTask { public bool stopPursueWhenClose = false; private bool mStopPursueWhenClose = false; private Vector3 targetPosition; private Transform targetTransform; private ActorLocomotion actorLocomotion; private ActorVision actorVision; private ActorMind actorMind; private ActorAttributes actorAttributes; protected override void OnExecute() { actorLocomotion = agent.GetComponent<ActorLocomotion>(); actorMind = agent.GetComponent<ActorMind>(); actorAttributes = agent.GetComponent<ActorAttributes>(); targetTransform = actorMind.curTarget; } protected override void OnUpdate() { Go(); } private void Go() { if (actorMind.curTarget == null) EndAction(false); if (!actorAttributes.isAggroed) EndAction(false); actorLocomotion.boltTarget = actorMind.curTarget.position; actorLocomotion.speed = 5; CompareDistance(); //EndAction(true); } private void CompareDistance() { float dist = Vector3.Distance(actorMind.curTarget.position, agent.transform.position); if (dist < actorAttributes.baseAttackRange / 2) { if (stopPursueWhenClose) EndAction(true); EndAction(true); } } protected override void OnStop() { actorLocomotion.speed = 3; } protected override void OnPause() { } } } |
Hello,
I really appreciate all the information provided, but it’s a bit hard to tell whats going on :/
Can you please send me some reproduction project ( info_at_nodecanvas.com )?
Thanks a lot,
Gavalakis Vaggelis
Hi, I sent an email with a link to the project and details on how to reproduce it.
Hello,
Sorry for being late.
I have replied to your email.
Please let me know.
Cheers!
Hi I am having the same problem right now, could let me in on what was causing it?
NVM! I think I figured it out… finny that I’ve been gnawing on this for 2 hours and got it 10 mins after posting here…
Essentially the GameObject got destroyed after I checked if it was null but before my outside ISense mono-behavior updated its list of objects in sense, so my node canvas grabbed null from it and tried to run with it.
I added a null check to the guilty Action task and that solved it.
Hello,
Glad to know it’s solved for you.
By the way, make sure to use CheckUnityObject in case you are actualy checking a UnityObject for null, instead of CheckVariable.
Cheers!
