Detecting clicking on an object

I am making some sort of builing game and having my first problem :slight_smile:

I have some objects on my terrain but i want to select them. How can i detect when i click on the mouse, witch object i can select? Do i have to cast a Ray from the camera and see if it’s collide with the object or is their an onClick event or some sort?

Try to reuse code of Dragrigidbody.js from Standard Assets

dragrigidbody.js was one of the first things I looked at when I started. It’s really tough to digest as a beginner :\

You could attach a script to your objects that has an OnMouseOver function and then inside it, detect if you’ve clicked the mouse button.