Camera destroy function throwing nil value/syntax error when using it in a scene overlay

I just have a quick question regarding the camera:destroy() function when using it in a scene overlay, while using the camera perspective in the base scene. I’m currently having a memory leak due to not being able to remove the perspective while using it in a scene overlay. When I call the destroy function anywhere in the overlay, it returns a syntax error saying that the destroy function is a nil value. It only happens when I display an overlay over a class that already has the perspective called. So for example, if I use the perspective in a class that does not have an overlay, it works perfect. Or, if I call an overlay but I don’t remove the perspective, the function will still work in the base scene when I change scenes.

The error only occurs when I try to remove the perspective from the overlay, while still displaying the base scene. An example of this would be if you used the perspective for level 1, as well as inside the scene overlay to call your game over menu. Using perspective, all image objects that are not using it appear behind anything that is. So in this instance, you’d have to use perspective in the game over menu as well. That is where my problem lies. So should I avoid using perspective in overlays if I am already using the perspective in the base scene, or is there a way around the error?

If anyone wants me to post code or the error being returned to the console, let me know.

Thanks,

Rob

Hm. Are you sure you’re not calling the function twice or accidentally using the same camera instance? As long as you’re using two separate camera systems, :destroy() shouldn’t have a problem wherever it’s called.

local camera1 = perspective.createView() local camera2 = perspective.createView() someCreepyCoreGroup:insert(camera1) aFriendlyPublicGroup:insert(camera2) camera1:destroy() camera2:destroy()
  • Caleb

Hey Caleb,

I managed to get it all working, the problem was a logic error on my end. It’s all working perfectly how it should now. Thanks for taking the time to respond, I appreciate it. I am loving the plugin, thanks for making it and amazing job.

Thanks again,

Rob

Hm. Are you sure you’re not calling the function twice or accidentally using the same camera instance? As long as you’re using two separate camera systems, :destroy() shouldn’t have a problem wherever it’s called.

local camera1 = perspective.createView() local camera2 = perspective.createView() someCreepyCoreGroup:insert(camera1) aFriendlyPublicGroup:insert(camera2) camera1:destroy() camera2:destroy()
  • Caleb

Hey Caleb,

I managed to get it all working, the problem was a logic error on my end. It’s all working perfectly how it should now. Thanks for taking the time to respond, I appreciate it. I am loving the plugin, thanks for making it and amazing job.

Thanks again,

Rob