i want to get child of other entity in collision can you help me ?
i’m getting “car1” with collision but i need to get “Text” can any one help me?
Hey, you can easily access the children of any entity if you have the entity reference.
This is how you can achieve it in this case. var text = Entity.children[0].children[0];
You can study more about the children’s property of the entity here Entity | PlayCanvas API Reference
Also, as it’s a generic question so you don’t need to mention the moderators specifically.
ok thanks
@saif
var text = AiCars.children[0].children[0];
console.log("text "+text);
in console the text is undefined
Hey @Saad_Maxamtech,
Are you sure the entity you’re accessing actually exists? I’d try to log the following:
console.log(AiCars);
console.log(AiCars.children[0]);
console.log(AiCars.children[0].children[0]);
This should help give you some clarity on what might be going wrong. Most likely, AiCars simply isn’t the entity you expect, and consequently it doesn’t have a grandchild at index 0.
thanks for your replay but i’m using another way that works fine