So i’m working on a game where you will need to click on the screen from your inventory to instantiate an object to place into the scene. Now I have the GUI all set up but what i’m not entirely sure is how to make it interact with my screen when I click it. For example when the mouse hovers over my cheese icon and clicks to lay down a cheese object in the scene…not sure how to make that happen. I’m sure i’ve read about something with making a grid on the screen so the game knows where you’re clicking but i’m not entirely sure how to make that happen. Any help is appreciated.
So a quick little update, I figured out how to click the button. I found a function for OnMouseDown and that seems to do the trick. But now we’re not entirely sure how to get the game to instantiate our object in a position of the players choice. One thought I had was to use the OnMouseDown function for the first click and an “if” for the second click to place the cheese. I haven’t been able to test it yet but it makes sense in my naive head.
But the other problem is we don’t know how to specify a location, I know a little about ray casting, would putting a ray cast on the mouse work to specify a location on the plane? Or does the program always know the location of the mouse cursor by default? Thanks again for the help.