I’m working on a VPS project using the Scavenger Hunt template, with 3 different spaces. I’m adding some UI elements to each space, some of which appear before the location has been found, which means they can’t be nested in the location. I’m getting some strange behaviour from them in the simulator. Sometimes the UI doesn’t appear at all, and sometimes the UI from a different space appears. Is there a way to lock them to the space, and make sure that they show only when that specific space loads?
Additionally, I need the UI elements to disappear when the space’s location is found. I have the following component to achieve this, but the way it is currently means that any location across the 3 spaces in the project being found makes the UI in all of the spaces disappear. I suspect this may be contributing to the strange behaviour described above, where sometimes the UI doesn’t appear at all. How can I modify this so that it only affects the UI in the current space?
import * as ecs from '@8thwall/ecs'
ecs.registerComponent({
name: 'hide-on-location-found',
schema: {},
stateMachine: ({ world, eid }) => {
const onLocationFound = () => ecs.Hidden.set(world, eid)
ecs.defineState('default').initial()
.onEnter(() => {
world.events.addListener(world.events.globalId, 'reality.locationfound', onLocationFound)
})
.onExit(() => {
world.events.removeListener(world.events.globalId, 'reality.locationfound', onLocationFound)
})
},
})