Pick a mesh with Ray

My game is a code-only game. The complete root scene is created on the fly with code. The scene has models and the models have multiple meshes.

Now I need to implement a feature: When the user clicks on screen, I should be able to get the references of the mesh and model at the clicked coordinates.

I have gone thru the phisycs/raycasting sample but I could not understand. It is using a script component and there is a field “simulator”. Not sure how this field is set.

Can you please help me achieve this in code-onlg fashion?

Thanks in advance.

Hey, I just recently was wondering the same! You can get the needed simulation variable by using this.GetSimulation(). Take a look at the TopDownRPG sample provided too, as it does this as well.