The null reference is because the blackboard is not assigned a reference. Try this code bellow and please make sure that this script is attached to a gameobject that has a Blackboard component attached as well, since we assign the reference by GetComponent from this gameobject.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
usingUnityEngine;
usingSystem.Collections;
usingSystem.Collections.Generic;
usingNodeCanvas.Framework;
publicclassFieldManager:MonoBehaviour{
publicBlackboard blackboard;
publicVector3 myPos;
voidStart(){
blackboard=GetComponent<Blackboard>();
myPos=blackboard.GetValue<Vector3>("myPosition");
}
}
Let me know if this works for you.
Cheers!
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.