- Home /
creating active objects or spots otherwise said HotSpots
As you can see in the development I have attached below, I have areas where users will click on to activate services lik skype, facebook etc I read somewhere about doing just that but I cannot find back where in the doc it is mentioned? Can somebody help me with this? Thanks yves
Comment
Answer by pyro · Jul 22, 2010 at 03:30 PM
You would create hotspots by attaching Colliders to the objects you want to be clickable.
Then use the Camera.ScreenPointToRay function to send a ray out where the user clicked and check if it hit one of your colliders.
function Update () {
if (Input.GetButtonDown ("Fire1")) {
// Construct a ray from the current mouse coordinates
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray)) {
//Check which object was hit and do something
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613065408im_/https://answers.unity.com/themes/thub/images/avi.jpg)