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

Null exception when applying NPC template #10

Open
Sanglyon opened this issue Apr 20, 2024 · 1 comment
Open

Null exception when applying NPC template #10

Sanglyon opened this issue Apr 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Sanglyon
Copy link

In Unity 2021.3.32f1, in a new project
Packages imported: CIVIL-AI, Synthy PolygonFarm

I put a Synthy character in my scene, unpacked the prefab then applied the NPC template to it.
A Null exception is raised, pointing to "Resources.Load("System/Objects/AI");" in AIOverviewManager.AddInNPCTemplate()

This is because Resources.Load search in a "Resources" directory which doesn't exist.
The RuntimeAnimatorController "AI.controller" is in "Assets/CIVIL-AI-SYSTEM/Animation Controller/Controller", so I fixed the issue by replacing

animator.runtimeAnimatorController = Resources.Load<RuntimeAnimatorController>("System/Objects/AI");

with

animator.runtimeAnimatorController = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>("Assets/CIVIL-AI-SYSTEM/Animation Controller/Controller/AI.controller");

------------------------------------------------------

Also, I made another change, but it's not technically a bug. Since the Synthy character already has an animator component with an avatar defined, I also replaced

Animator animator = selected.AddComponent<Animator>();

with

Animator animator;
if(!selected.TryGetComponent<Animator>(out animator))
{
animator = selected.AddComponent<Animator>();
}

@Sanglyon Sanglyon added the bug Something isn't working label Apr 20, 2024
@IsaacMulcahy
Copy link
Owner

IsaacMulcahy commented Apr 20, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants