So I want to make a tic tac toe game but with as little GUI functions at possible.
So is it possible to check if an object has been clicked and what object it was and then do something with that?
Hopefully you guys understand cause you are smart people.
Well there is 9 boxes, two teams, each team has its own symbol. With that logic you will need to put a turn based system with the addition of a click-to-place symbol in one of the boxes. So once Player 1 clicks on a box(likely a raycast that checks if a symbol is allready there, and if there is nothing then place it down) then the turn is Player 2, and the proccess starts over again. Then you need to check the boxes to see if there is any 3 of the same symbols lined up and whoever owns that symbol wins. Thats my run down of it anyways. Sorry that i can’t help with the code, im just a noob…
What you’re looking for is a raycast.
Have 9 box colliders representing your 9 squares; perform a raycast using mouse position (as shown in the examples); then use hit.collider to determine which object you hit.
Thanks a lot guys. I had a suspicion that i had to use raycast but wasn’t sure.
Thanks for confirming it and Helping me!
If the objects have colliders on them and the script on the object in question you could always just the use the builtin OnMouseDown function as well…