Forums › 💬 NodeCanvas › ⚙️ Support › Project crash when upgrading from U5.4.3 to U5.5.3 › Reply To: Project crash when upgrading from U5.4.3 to U5.5.3
Haha 🙂 Thanks a lot! I hope you had/have a great summer time as well!
I am glad to hear that you’ve managed to overcome the problem even though it took a bit of manual work. Just to confirm, was I correct to assume that you were using a NodeCanvas version before 2.6.2? Is everything works correctly now after upgrading?
Regarding changing FindAllWithTag to use a BBParameter, it is possible, but you will also need to change the OnExecute code to use ‘searchTag.value’ instead of simply ‘searchTag’. ‘searchTag.value’ will correctly return the string assigned to the BBParameter. Here is the full changed code for you:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
namespace NodeCanvas.Tasks.Actions{ [Category("GameObject")] [Description("Action will end in Failure if no objects are found")] public class FindAllWithTag : ActionTask{ [RequiredField] [TagField] public BBParameter<string> searchTag = "Untagged"; [BlackboardOnly] public BBParameter<List<GameObject>> saveAs; protected override string info{ get{return "GetObjects '" + searchTag + "' as " + saveAs;} } protected override void OnExecute(){ saveAs.value = GameObject.FindGameObjectsWithTag(searchTag.value).ToList(); EndAction(saveAs.value.Count != 0); } } } |
I think the same can be said for the GetOverlapSphereObjects. When a BBParameter is used, remember to use it’s ‘.value’ property instead of the BBParameter object itself. Here is the 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 |
namespace NodeCanvas.Tasks.Actions{ [Category("Physics")] [Description("Gets a lists of game objects that are in the physics overlap sphere at the position of the agent, excluding the agent")] public class GetOverlapSphereObjects : ActionTask<Transform> { public BBParameter<LayerMask> layerMask; public BBParameter<float> radius = 2; [BlackboardOnly] public BBParameter<List<GameObject>> saveObjectsAs; protected override void OnExecute(){ var hitColliders = Physics.OverlapSphere(agent.position, radius.value, layerMask.value); saveObjectsAs.value = hitColliders.Select(c => c.gameObject).ToList(); saveObjectsAs.value.Remove(agent.gameObject); if (saveObjectsAs.value.Count == 0){ EndAction(false); return; } EndAction(true); } public override void OnDrawGizmosSelected(){ if (agent != null){ Gizmos.color = new Color(1,1,1,0.2f); Gizmos.DrawSphere(agent.position, radius.value); } } } } |
If you want to default the LayerMask parameter to an integer value, you can do this:
public BBParameter<LayerMask> layerMask = new BBParameter<LayerMask>{ value = -1 };
Please let me know if that works for you. 🙂
Thanks!
