.onExit() state machine error on latest Studio update

Since the latest I am getting this error in the editor when i play the scene in the simulator

Uncaught Error: Failed to establish cursor
    at Object.cursor runtime.js
    at Object.onExit ObstacleController.js:35:22
    at (anonymous) runtime.js
    at r runtime.js
    at (anonymous) runtime.js
    at (anonymous) runtime.js
    at r runtime.js
    at J runtime.js
    at K runtime.js

Here is the line of code being referenced

.onExit(() => {
        dataAttribute.cursor(eid).gameActive = true
      })

The game still runs fine in the live version but breaks in the simulator.

1 Like

For context, the “Failed to establish cursor” error will occur if you attempt to access a cursor on an entity that doesn’t have that component/attribute.

In this case, the onExit for the state machine is running during component teardown, and the dataAttribute has already been removed. This seems to be an oversight and we’ll plan to reorder those operations in a future release.

dataAttribute.set(eid, {gameActive: true}) would not have this issue.

Additionally the reason this code that previously had no errors, is now having an error, is due to a tweak in the way the live sync connection is initiated. Now, we remove all scene content and fully reload the scene with the latest state from the editor, which tears down state machines and re-initializes them from their initial state.

1 Like

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.