Raycasting and Layer Masks problem

I want to have various ‘info points’ set up across my scene that contain a unique ID(stored as an int). When the player clicks on one of these points a GUI window will pop up and display the relevant info based on the supplied ID. I’m using raycasting and setting a layer mask to make contact with the info points. This works great with one info point…

However, when I add more than one I’m getting one window for each info point display at the same time. I can understand there may be a conflict here from using one layer mask - Is there any way to filter these objects based on their ID or will I need to take a different approach on this?

Unless I misunderstand your question, it’s fortunately very easy – just use the .name of the collider you have hit …

inside Update() on something attached to the scene...
if ( Input.GetMouseButtonDown(0) )...
yellowRay = theCamera.ScreenPointToRay( Input.mousePosition ) ..
if ( Physics.Raycast(yellowRay, theHit, 5.0) ..
.. print("name is .. " + theHit.collider.name_)
.. if (theHit.collider.name == "myFirstSignThing") 
.. if (theHit.collider.name == "myOtherSignThing")

and so on. If that doesn’t do it for you, you probably just have some basic code error unrelated to the physics and you’d have to post the code. Hope it helps.

You can also use OnMouseDown(), or similar, and lose the raycast. Something like:

public int infoID;
public string someText;

void OnMouseDown() {
  GameObject.Find("infoGUI").GetComponent<infoGuiScript>().show(infoID, someText);
}

infoGuiScript is attached to the one infoGUI object, which swaps out content on each call to show.