Detect when reaches cactus on sample project

Hi, when dealing with the cactus sample project how we can detect the user walks into the mesh? We tried adding a static collider to both camera and cactus but without success, we added a listener to ecs.physics.COLLISION_START_EVENT settings. We want to capture each of the cactus around the area . thank for any help

You could also consider calculating the distance between the camera and each cactus on tick():

const cactusPosition = ecs.math.vec3.from({
  x: ecs.Position.get(world, cactus).x,
  y: ecs.Position.get(world, cactus).y,
  z: ecs.Position.get(world, cactus).z,
})
const cameraPosition = ecs.math.vec3.from({
  x: ecs.Position.get(world, camera).x,
  y: ecs.Position.get(world, camera).y,
  z: ecs.Position.get(world, camera).z,
})

const distance = cactusPosition.distanceTo(cameraPosition)

if (distance !== 0 && distance < distanceThreshold) {
  // collect the cactus
}

Similar functionality is demonstrated in this community sample:

Thank you, may i ask how can i get access to an entity? Ecs. Doesnt have any getby of something else, world. Class too.

I have the cactus in the scene and i want to access to it to change some property (disabled to enabled) in another typescript script.

I just started to study 8thwall yesterday .

You can access the eid of the entity the component is attached to with component.eid.

You can reference the eid of another entity by adding a schema value and specifying the entity from the custom component configuration in the properties panel.

ecs.registerComponent({
  name: 'cactus',
  schema: {
    camera: ecs.eid,
  },
  tick: (world, component) => {
    const cactusPos = ecs.Position.get(world, component.eid)
    const cameraPos = ecs.Position.get(world, component.schema.camera)
  },
}