I wanted to convert a script to 0.3. We can’t use overlays anymore so we need to use collection. That is fine, however i don’t get it to work.
I call it with python
def test(cont):
own = cont.owner
own.scene.addOverlayCollection('hud_camera','Hud')
I get the following error
Failed to convert collection.
Error: Python(Cube), Python script error
Traceback (most recent call last):
File "C:\Users\germe\Desktop\test.blend\script.py", line 5, in test
SystemError: <method 'addOverlayCollection' of 'KX_Scene' objects> returned NULL without setting an error
So i thought maybe i need to uncheck the checkbox from the hud collection… Instant crash, blender just closes itself. Then i thought well maybe it needs to be invisible, so i click the eye icon, same error occurs.
Why make a way around it, while there is an option build-in for it?
If it’s a bug then ill wait, i do not need a work around. If i did something wrong then tell me what i did wrong.
Ok, looked at docs and can’t find this part, and to be honest i’m clueless about what to do here. Is it possible for you to make an example of it?
I agree, i’ve seen this in the docs and can be very useful, but to use that instead of a build-in option seems a bit odd to me. That’s why i just want to use the build-in option.
Thanks a lot got it to work, i find it a bit strange to make it work like this, need to getting used to it i guess. For the people who are figuring this out aswell, here is a .blend.
# uncheck all eye icons from the collection that you...
# want to have as an overlay, but keep the camera checked.
import bpy
def test(cont):
own = cont.owner
keyboard = cont.sensors['Keyboard']
#check is needed to counter double activation
if keyboard.positive:
collection = bpy.data.collections['Hud']
cam = own.scene.objects['hud_camera']
own.scene.addOverlayCollection(cam, collection)
Turns out if I add an overlay collection and I code the script to use the overlay collection’s camera, this will cause a momentary start freeze for a few seconds, and all objects lose their physics. If I do it with a non-hidden camera in the scene, objects won’t lose their physics, there is no frame drop or a starting freeze upon running. Is there an explanation for this?
EDIT: The collection doesn’t seem to display when I try to display it on a visible camera in the scene despite it being added to the camera as an overlay upon running. The camera is visible, and the overlay collection is hidden.