Seek last known position gameobject returns null

dimitur_kolev2

New member
Hi guys, Im trying to make a last seen position system and I have a problem.I have an enemyAI script that references both an empty LastSightPosition object and the player gameobject.
Inside a method i make the last sight position the same as the player position and Ive also attached a sphere to make sure it works well and it does.
In the behavior tree i check if the player is in sight > if he is I call the method.
I have another branch that evaluates if he is not in sight and everything seems ok but when i put in target the lastSightPositionGameObject it returns null and the seeking stops at 0,0,0 and returns success.
Ive tried with Pursue and it works but still gives me an error saying the LastSightPositionGameObject is null
Am I missing something obvious here?
BTW amazing plugin :)
135135.PNG
 
Glad you are enjoying Behavior Designer!

In general it sounds like you have the right approach but if a variable is being set to null then chances are one of your tasks is setting that variable at a time that you don't expect. One debugging tip is to disable unnecessary tasks and just have the interested tasks enabled so you can pinpoint what is causing the issue.
 
Glad you are enjoying Behavior Designer!

In general it sounds like you have the right approach but if a variable is being set to null then chances are one of your tasks is setting that variable at a time that you don't expect. One debugging tip is to disable unnecessary tasks and just have the interested tasks enabled so you can pinpoint what is causing the issue.
Yup I managed to fix it.It appeared that the assigned variable is lost on scene reload and becomes null - so at start of the tree i set the sharedgameobject to the lastposition and the error went away..
 
Top