# Studio - VPS Mesh/Location found and lost events based trigger

**URL:** <https://forum.8thwall.com/t/studio-vps-mesh-location-found-and-lost-events-based-trigger/8294>\
**Category:** Technical Support\
**Tags:** vps, studio\
**Created:** [September 17, 2025, 11:07pm UTC](https://forum.8thwall.com/t/studio-vps-mesh-location-found-and-lost-events-based-trigger/8294 "2025-09-17T23:07:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Camilleri](https://avatars.discourse-cdn.com/v4/letter/c/9de0a6/32.png) [@Chris\_Camilleri](https://forum.8thwall.com/u/Chris_Camilleri)\
**Post date:** [September 17, 2025, 11:07pm UTC](https://forum.8thwall.com/t/studio-vps-mesh-location-found-and-lost-events-based-trigger/8294/1 "2025-09-17T23:07:39Z")

</div>

Hi there, I am trying to work on a project based on multiple VPS locations. We are wanting to have a target real world object image pop up on the screen as a starting point in the storytelling journey which guides the user to what needs to be scanned. I want the image to disappear when that particular VPS mesh/location is found and reappear it when the mesh is lost.

I have the images as a overlay group and using the following script on individual VPS location to trigger the enabling an disabling of these images.

```typescript
import * as ecs from ‘/ecs’

ecs.registerComponent({name: ‘EnableOnVPSLocation’,schema: {locationName: ecs.string, // Name of the VPS location (from Geospatial Browser)targetEntity: ecs.eid // Entity to enable/disable},

add: (world, component) => {const {eid, schema} = component

const enableTarget = () => {
  if (typeof schema.targetEntity === 'number') {
    ecs.Disabled.remove(world, schema.targetEntity)
    console.log(`[EnableOnVPSLocation] Enabled target entity ${schema.targetEntity}`)
  }
}

const disableTarget = () => {
  if (typeof schema.targetEntity === 'number') {
    ecs.Disabled.set(world, schema.targetEntity, {})
    console.log(`[EnableOnVPSLocation] Disabled target entity ${schema.targetEntity}`)
  }
}

world.events.addListener(world.events.globalId, 'reality.locationfound', (e: any) => {
  const {name, position, rotation} = e.data

  if (name === schema.locationName) {
    // Show and update position/rotation of this component's entity
    ecs.Hidden.remove(world, eid)
    ecs.Position.set(world, eid, position)
    ecs.Quaternion.set(world, eid, rotation)

    // Enable the target entity
    enableTarget()
  }
})

world.events.addListener(world.events.globalId, 'reality.locationlost', (e: any) => {
  const {name} = e.data

  if (name === schema.locationName) {
    // Hide this component's entity
    ecs.Hidden.set(world, eid, {})

    // Disable the target entity
    disableTarget()
  }
})

```

can you please explain if this approach is right or is there a easier way to achieve this?  
I have also tried another approach using MESH NAME as variable and not have the script attached to the vps itself. That did not work either. What am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![GeorgeButler](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/georgebutler/32/1903_2.png) [@GeorgeButler](https://forum.8thwall.com/u/GeorgeButler)\
**Post date:** [September 18, 2025, 6:17pm UTC](https://forum.8thwall.com/t/studio-vps-mesh-location-found-and-lost-events-based-trigger/8294/2 "2025-09-18T18:17:33Z")

</div>

This is the correct approach. Very similar to the [custom Image Target components](https://www.8thwall.com/8thwall/image-targets/code/magic-photos/video-pause-on-lost.ts)you’ll see in Sample Projects.
