The object of type 'VRTK_TransformFollow' has been destroyed but you are still trying to access it.
See original GitHub issueEnvironment
- Source of VRTK - Github
- Version of VRTK Github master commit hash 90e829d
- Version of Unity3D - 5.6.0f3
- Hardware used - Vive
- SDK used SteamVR
Steps to reproduce
In an empty scene “SceneA” I have one script following methods:
void Start () {
DontDestroyOnLoad(this);
SceneManager.LoadScene("003_Controller_SimplePointer");
}
void Update () {
if (Input.GetKeyDown("l"))
SceneManager.LoadScene("SceneB");
}
In “003_Controller_SimplePointer” I have moved all objects into an empty parent object and added in a script:
void Start () {
DontDestroyOnLoad(this);
}
On the press of “l” on the keyboard, as seen in the first script, I load “SceneB” which has just a cube in it and nothing else.
“SceneB” and it’s cube do load into “003_Controller_SimplePointer” but then it starts spewing the error:
MissingReferenceException: The object of type ‘VRTK_TransformFollow’ has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. VRTK.VRTK_BasePointerRenderer.UpdatePointerOriginTransformFollow () (at Assets/VRTK/Scripts/Pointers/PointerRenderers/VRTK_BasePointerRenderer.cs:295) VRTK.VRTK_BasePointerRenderer.FixedUpdate () (at Assets/VRTK/Scripts/Pointers/PointerRenderers/VRTK_BasePointerRenderer.cs:255)
Expected behavior
Controllers continue behaving correctly as per before “SceneB” is loaded.
Require controllers to be persistent and load different scenes as required.
Current behavior
The above error appears, controllers are tracking, but no functionality.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
I tried SetActive false/true on [VRTK] object but it did not work. But if I get “Controller (left)” and “Controller (right)” after they have loaded, SetActive(false) on each of them, load scene in, then SetActive(true) on each again, there are no errors and controllers seem to act as they should. I’ll move forward with this solution unless someone has a better suggestion. Thanks @bddckr for pointing me in this direction!
@bddckr will have a look at your suggestion and get back with results. Thanks.