How to make a child entity disappear,95655154
I’m trying to have the child entity bullet disappear whenever it makes contact with any other entity, but I keep getting an error saying “Cannot read properties of undefined (reading ‘destroy’).” Can anyone help me with this? Please and thank you.

Hi @Glast! Your problem is related to the topic below.

Other than that, I can’t see where you define this.bulletChild. So even when you apply the fix of the topic above, you will probably get the same error. The entity with the script has also no child entities, so I’m curious what you try to achieve.

Hi Glast,

I was able to open your project and have a quick look in the editor. From what I see you clone the bullet inside of first-person-movement.js when you push the left mouse button to fire. Shortly there after you delay 4000 and then .destory() it. When you look for your collision contact I see a possible issue. One is that it the bulletChild has already been destroyed by the timeout. ← this would cause the object pointer to be non existent. Thus throwing the error. I do see that you are cloning the bullet but I am not sure that the pointer is valid at the time your contact happens. Still thinking about how you could fix this.

1 Like

Ah, I was looking at your bulletContact script. You can ignore my reply for now, but maybe it can help you in the future. Hopefully the reply of @Tirk182 can help you here.