Scene.frame_set() does not seem to work with linked objects and collections

If I use any linked object in UPBGE 0.3.6.1 that uses a geometry node modifier and a script attached that drives the modifier using scene.frame_set(), a strange bug causes the object’s geometry node modifier to reset to frame zero.

The geometry node modifier will work fine in the original file, so this sounds like a bug.

To reproduce, follow these steps:

  1. Open UPBGE 0.3.6.1 and create an object with any geometry modifier with any effect that moves vertices.

  2. Write a piece of code that uses the scene.frame_set() module and add 1 to it every frame in the script so it will make the modifier run. Make sure the sensor is set to True, and attach the code to a module or Text Python controller, and connect the Always Sensor to the Python Controller.

  3. Save the file, and link the object into a new scene or file. Start the Game Engine. Your object’s geometry node modifier will be frozen, as if time is stopped at frame zero.

It seems to be a bug with 0.3.6.1’s scene.set_frame() that causes it to default to frame zero, which is not an intended behaviour.

Geonodes are faster in quite a few cases, and are about to become much faster with the switch from CPU to GPU-based vertex rendering, and having a geonode modifier that is stuck at frame zero, yet working fine in the original file breaks the look of many things that can be created with geonodes in UPBGE like water, smoke, fire, etc.

Is there a workaround to make the object’s geometry node respond to scene.frame_set() when it increases or decreases when I script it to, and then link the object?

Can you attach a test blend (created in 0.3)?

That wouldn’t be possible, as UPBGE reads the linked file’s object upon opening the file. I don’t like uploading, as what is on the internet, stays on the internet. As said before, please follow the steps I created to test this bug.

Created a keyframed geo-node driven by python
bpy.data.scenes['Scene'].frame_set(own['frame'])

Linked obj with animation works in 0.3 , 0.36.1 and 4.1 Alpha (Windows10).

Sorry for you.

Ah. I must be doing something wrong in my script or modifier.

obj to test for linking

untitled.blend (837.2 KB)

script used on the object:

import bge
import bpy

cont = bge.logic.getCurrentController()
own = cont.owner
if 'frame' not in own:
    own['frame']=0
bpy.data.scenes['Scene'].frame_set(own['frame'])
own['frame']+=1
if own['frame']>40: own['frame']=0

print (own['frame'])

I also found out that when I try and link any collection object, change it’s location, rotation, or scale, it will just default to it’s original scaling and location. Why? Nothing is wrong with my objects at all.

I tested your file, and it worked. To test even further, I linked the cube into my file, and tested it there. Worked also. I must have written my script incorrectly. I hope this minor bug gets fixed someday, it’s inconvenient, I then deleted the cube, as I no longer needed it.

Rotations etc. should work.
This was the first thing I tested and the rotation-code is still in the posted blend-test file but it’s out-commented. :slight_smile:

This is all you need to test Rotatiion:

import bge
cont = bge.logic.getCurrentController()
own = cont.owner
own.applyRotation((0,0,0.1),False)

Did some more testing with a sea I created. When I linked it with the “Instance Collection” and “Instance Object Data” unchecked, the object worked again like magic. It sounds like modifier playback for linked collections isn’t fully supported yet or a bug is preventing proper modifier functionality, although based on my findings, it sounds like the feature is partially implemented, as logic and physics functionality still works.

The only caveat to this is that you cannot ever change the size or location of the object, which breaks level design. Even if you parent an Empty to the object, the size will not change in accordance with the Empty.

Instead, use a “Library Override” to move the object. This will also fix the scaling issue.