# Object trigger based on component

**URL:** <https://forum.8thwall.com/t/object-trigger-based-on-component/3204>\
**Category:** Technical Support\
**Created:** [October 17, 2024, 12:31am UTC](https://forum.8thwall.com/t/object-trigger-based-on-component/3204 "2024-10-17T00:31:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jessica\_Sheng](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@Jessica\_Sheng](https://forum.8thwall.com/u/Jessica_Sheng)\
**Post date:** [October 17, 2024, 12:31am UTC](https://forum.8thwall.com/t/object-trigger-based-on-component/3204/1 "2024-10-17T00:31:54Z")

</div>

```auto
ecs.registerComponent({
  name: 'mergeHandler',
  schema: {
    // collisionComponentTarget: ecs.string,
    object2: ecs.eid,
    entityToSpawn: ecs.eid,
    scale: ecs.f32,
    spawnPositionY: ecs.f32,
  },
  schemaDefaults: {
    scale: 1.0,
    spawnPositionY: 1,
    collisionComponentTarget: '',
  },

  add: (world, component) => {
    world.events.addListener(component.eid, ecs.physics.COLLISION_START_EVENT, ({data}) => {
      console.log('collision: ', data)
      ...
    if (component.schema.object2 === data.other) {
        console.debug('touched!')
        spawnObject()
      }

```

I am currently trying to create this workflow: Object with a specific component (or attribute within component, not sure what would be the best practice yet) collides with this.obj (component.eid) to spawn something else. As of right now, my code is detecting collision with component.eid and object2. I have been looking through the documentation, but I am not too sure how to get/read a certain component attached to a specific object. Would I be using getAttribute() for this? It seems to get getting schemaAttributes rather than component name.
