Problem with more entities with same name

Hello, if i have more entities with the same name how can i identify it when clicking? if i use entity.getName i get the first entity in the hierarchy with that name but not the one i click…how do i solve this?
Edit: i remembrer is possible to get entity id but didn’t find anything…am i wrong?

Hi Ayrin,
Why do you need the name? If you are using raycast to click an entity then the result is the entity so you don’t really need the name.

    var from = this.entity.camera.screenToWorld(e.x, e.y, this.entity.camera.nearClip);
    var to = this.entity.camera.screenToWorld(e.x, e.y, this.entity.camera.farClip);

    this.app.systems.rigidbody.raycastFirst(from, to, function (result) {
        var pickedEntity = result.entity;

        pickedEntity.script.pulse.pulse();
    });

Mmmmh you are right mrLoganite, i was mislead by my mind. I didn’t see the solution before my eyes. thanks a lot.

1 Like