# Issues with Registering Custom Component in 8th Wall ECS

**URL:** <https://forum.8thwall.com/t/issues-with-registering-custom-component-in-8th-wall-ecs/2980>\
**Category:** Technical Support\
**Tags:** general\
**Created:** [September 30, 2024, 9:14pm UTC](https://forum.8thwall.com/t/issues-with-registering-custom-component-in-8th-wall-ecs/2980 "2024-09-30T21:14:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Divakar\_sarika1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@Divakar\_sarika1](https://forum.8thwall.com/u/Divakar_sarika1)\
**Post date:** [September 30, 2024, 9:14pm UTC](https://forum.8thwall.com/t/issues-with-registering-custom-component-in-8th-wall-ecs/2980/1 "2024-09-30T21:14:14Z")

</div>

I’m currently working on a project using 8th Wall ECS, and I’m trying to create a custom component called `destructible` that fades out and deletes a GLB model when it collides with a projectile. heres the code import \* as ecs from ‘[@8thwall](https://forum.8thwall.com/groups/8thwall)/ecs’

// Register the ‘destructible’ component  
ecs.registerComponent({  
name: ‘destructible’,  
schema: {  
fadeDuration: ecs.types.F32,  
},  
init() {  
// Optional: Initialize component-specific data here  
},  
tick(world, entity) {  
// No specific action in the tick for this component  
},  
events: {  
// Handle collision events here  
collision(world, entity, collisionData) {  
const {otherEntity} = collisionData

```
  // Check if the other entity is tagged as a 'projectile'
  if (world.hasComponent(otherEntity, 'projectile')) {
    this.fadeOutAndDestroy(world, entity, this.properties.fadeDuration)
  }
},

```

},  
methods: {  
// Method to fade out and destroy the model  
fadeOutAndDestroy(world, entity, duration) {  
let opacity = 1 // Start at full opacity  
const fadeInterval = world.setInterval(() =\> {  
opacity -= world.time.delta / duration  
if (opacity \<= 0) {  
world.deleteEntity(entity) // Delete the entity once fully faded out  
world.clearInterval(fadeInterval) // Clear the interval once the entity is removed  
}  
// Assuming you have a material component with opacity control  
ecs.Material.set(world, entity, {opacity})  
}, 1000 / 60) // Update opacity every frame (60 FPS)  
},  
},  
})  
"

 ![Screenshot 2024-10-01 005730](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/4/4f34eca905f3c9a3cb417da58765029873d1fc27.png)

---

<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 30, 2024, 9:22pm UTC](https://forum.8thwall.com/t/issues-with-registering-custom-component-in-8th-wall-ecs/2980/2 "2024-09-30T21:22:26Z")

</div>

> **[Component schema | 8th Wall](https://www.8thwall.com/docs/studio/guides/components/component-schema/#data-types)**
>
> component-schema}

❌ `ecs.types.F32`

✅ `ecs.f32`

😃

By the way ‘methods’ won’t work that way. You should add the method inside the `add` hook on the Custom Component. If that doesn’t work, I’d recommend looking into setting up an broadcast / listener pattern.
