Reply by k3kalinix | 2024-08-19 22:21:47
Just say, refactor this code.
Reply by k3kalinix | 2024-08-19 22:21:47
Just say, refactor this code.
Reply by k3kalinix | 2024-08-19 22:21:53
Make it clean
Reply by k3kalinix | 2024-08-19 22:21:58
Understandable
Reply by k3kalinix | 2024-08-19 22:22:59
Easily changeable
Reply by k3kalinix | 2024-08-19 22:23:45
In short, according to the SOLID principle.
Reply by newbietechbro | 2024-08-19 23:11:00
It seems like adding the Coroutine made it worst, as prior to adding it, the Mainscene would unload if the tracked image for the CharacterTour scene was detected (it only did not work the other way around), but now either way doesn’t work
Reply by k3kalinix | 2024-08-20 00:12:15
Doing this requires some code knowledge and Unity knowledge.
Maybe you changed something or implemented it wrong.
When I test it the same way, it works fine.
Reply by k3kalinix | 2024-08-20 00:17:14
I don’t know your project.
Reply by newbietechbro | 2024-08-20 11:18:52
I do have code and Unity knowledge
Reply by newbietechbro | 2024-08-20 11:22:39
Do you or someone at Convai have samples where the ar scene is an additive scene?
Reply by k3kalinix | 2024-08-20 11:36:54
Did ChatGPT write this code or did you write it?
How can we provide a sample of this?
This is a normal Unity scene. It only requires a coroutine and the UnloadSceneASYNC method.
Reply by newbietechbro | 2024-08-20 12:06:42
I wrote it
Reply by newbietechbro | 2024-08-20 12:07:33
Well, for whatever reason, the Convai AR scene doesn’t unload properly, but all my other scenes unload fine
Reply by newbietechbro | 2024-08-21 13:40:00
For future reference for anyone also encountering the same issue, I figured it out. In the CoRoutine, before unloading the additive scene, I made sure to use Game.Object.FindGameObejctsWithTag
(“Tag the NPC”) to explicitly destroy the NPC and any related game objects before unloading the scene that it is in.
Reply by newbietechbro | 2024-08-21 13:40:06
Example:
GameObject objectsToDestroy = GameObject.FindGameObjectsWithTag(“CharacterTour”);
foreach (GameObject obj in objectsToDestroy)
{
Debug.Log(“Destroying object tagged CharacterTour”);
Destroy(obj);
Debug.Log(“Destroyed an object tagged CharacterTour.”);
yield return new WaitUntil(() => obj == null);
}
Reply by k3kalinix | 2024-08-21 13:40:47
Awesome, thank you for sharing.
<:1000:892567147535015997>
This conversation happened on the Convai Discord Server, so this post will be closed.