Click on the model question

I want to get the name of the object that I clicked on, what should I do?

The object I clicked on was a whole made up of many objects, but I wanted to know the exact name of the model.

Hi @han,

If the object is made of multiple entities, then you can use the picking with physics, the rigidbody raycast method. It will return the entity name of the entity found when clicking, here is an example:

If the object is a single model with multiple mesh instances, then a solution is to create a shape (pc.BoundingBox or pc.BoundingSphere) for each mesh instance. Then use a picker that casts a ray for each shape in scene, like this example:

Thinks.I’m trying to use the picker,But the accuracy of the picker seems inadequate,How can I improve the accuracy of the picker?

What do you mean the accuracy is inadequate? When you click one entity it selects the other? That shouldn’t happen unless there’s something wrong with your code. Could you share a project link?

Also, I added OrbitCanera to my project. Will it have any impact?

At this point, without taking a look at the project it’s hard to tell what is the issue @han.

You can pick using the framebuffer which leads to a frame drop or two but is a lot more accurate


Sorry, I may not be able to share the link because I’m using a local engine pulled down from GitHub

This approach is perfect, although it consumes performance, but it is really a perfect solution.