crashkonijn / GOAP

A multi-threaded GOAP system for Unity
Apache License 2.0
1.16k stars 127 forks source link

Bug: "KeyNotFoundException: No action found of type WanderGoal" potential AgentBehaviour bug #83

Closed kadallah closed 1 year ago

kadallah commented 1 year ago

Describe the bug I'm currently trying to follow along the tutorial, and it seems like I'm getting stuck just at the very end. I was having trouble figuring out how to add/configure the Agent Behaviour component, so I added the one that was imported here: Assets/Imported/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs

Now, when I hit play, I get the following error:

KeyNotFoundException: No action found of type WanderGoal CrashKonijn.Goap.Classes.GoapSet.ResolveGoal[TGoal] () (at Assets/Imported/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Classes/GoapSet.cs:53) CrashKonijn.Goap.Behaviours.AgentBehaviour.SetGoal[TGoal] (System.Boolean endAction) (at Assets/Imported/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs:181) AgentBrain.Start () (at Assets/Scripts/AgentBrain.cs:15)

I believe that I configured everything else correctly, but please let me know if there is anything I should check specifically.

Steps to Reproduce Steps to reproduce the behavior:

  1. Import asset from Unity through the Package Manager.
  2. Follow the tutorial.
  3. Add the imported AgentBehaviour component to agent.
  4. Press play.

Expected behavior The agent should wander without any specific goal.

Unity Version 2022.3.9f1

Unity.Collections Version Please mention the Unity.Collections version you are using.

Package Version Please mention the package version you are using.

Additional context It might be worth it to mention that I'm using this in a 3D project, so the Agent GameObject also has a NavMeshAgent. I've tried running with it both on and off.

Thank you for your hard work! This documentation has been amazing thus far (even if I haven't quite gotten this to work yet).

crashkonijn commented 1 year ago

Hi there @kadallah!

Thanks for your detailed report, that helps a lot!

The error means that no WanderGoal has been added to the GoapSet configuration.

Are you using the setup through ScriptableObjects or code?

If you're using the SO's, it should be set up like this, shown in step 9: image

If you're using code it should be step 5 image

Please let me know if this fixes your issues, or if you're still running into trouble!

Ps. If you run into more issues you could join our Discord, I can help you quicker there 😄

kadallah commented 1 year ago

Hi, thanks for the speedy reply. I'm using SO and I think I have this configured correctly: Screenshot 2023-10-07 143115.

I just joined the Discord. I may ask for some more help over there during the week, but for now I'll stick here in case someone else runs into the issue and finds the troubleshooting helpful. Unless you'd prefer to triage over there.

crashkonijn commented 1 year ago

Hi again!

That does seem like you've set it up correctly!

Is there any chance you have a WanderGoal from the demo, and your own from the tutorial in the project?

I think you might have added one in your setup and are calling SetGoal with the other one. At least that would explain this.

kadallah commented 1 year ago

Screenshot 2023-10-09 125308

This is the WanderGoal that's attached to my GettingStartedSet. As you can see, this is the one that I've created, not the one that was imported. Is there anywhere else that I should check?

crashkonijn commented 1 year ago

We resolved this on Discord.

It was indeed a mixup between different classes in the config and the actual class being used in the agent brain.

Thanks again for all your info and your descriptive bug report!