-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix node method calls #25
base: main
Are you sure you want to change the base?
Conversation
return; | ||
|
||
if (status == NodeStatus.Running || (_node != null && value.index - node.index < 0)) | ||
if (Status == NodeStatus.Running || (_node != null && value.Index - _node.Index < 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here would be nice to understand
_node != null && value.Index - _node.Index < 0
Runtime/Proc/ExecutionContext.cs
Outdated
} | ||
|
||
last = _node; | ||
StepOut(_node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nice to ensure that this is always called when the next code is set.
cannot test before sunday but the changes look good from here. |
|
||
private void StepOut(ExecutableNode node) | ||
{ | ||
if (!node.Memory.TryGetValue(Agent.GetInstanceID(), out object memory)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private void StepOut(ExecutableNode node)
{
UnityEngine.Debug.Log($"Node: {node}");
UnityEngine.Debug.Log($"node.Memory: {node.Memory}");
UnityEngine.Debug.Log($"Agent: {Agent}");
UnityEngine.Debug.Log($"Agent.GetInstanceID(): {Agent.GetInstanceID()}");
if (!node.Memory.TryGetValue(Agent.GetInstanceID(), out object memory))
return;
// [...]
}
This happens directly at tree initialization.
context.node = nodes.FirstOrDefault(x => x.nodeType == ExecutableNode.ExecutableNodeType.Root);
Since you call FirstOrDefault, a bit defensive programming could help here I recommend.
I've added
if (!node)
return;
before
if (!node.Memory.TryGetValue(Agent.GetInstanceID(), out object memory))
return;
Then the error disappears but then the tree doesn't run properly anymore. I'm using Wait nodes and they don't seem to use the memory anymore. With 10 enemies I'm having 10 FPS and the tree runs more than 250 times (my setting) per fps with only wandering node and 2 conditionals (both with self abort) active. When they recognize me, the fps counter shows less than 1 fps.
Something is going on there. Maybe it has to do something with the Node Memory or the conditional memory.
Should fix #23? Still need to do some testing.