Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fix node method calls #25

wants to merge 3 commits into from

Conversation

acdamiani
Copy link
Owner

Should fix #23? Still need to do some testing.

return;

if (status == NodeStatus.Running || (_node != null && value.index - node.index < 0))
if (Status == NodeStatus.Running || (_node != null && value.Index - _node.Index < 0))

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

}

last = _node;
StepOut(_node);

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.

@ijisthee
Copy link

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))
Copy link

@ijisthee ijisthee Mar 3, 2024

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;

    // [...]
}

Results in:
image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing OnNodeExit() Call on conditional node abort
2 participants