Unity 2D Raycast Collision Detection
Hello everybody! I am currently trying to make a 2d space RTS game, which implies that the player has to be able to click on the unit, click anywhere on the game field, and the unit should be able to travel there. I am stuck on the point selection part. I thought about using a tile system for that, but, for some reason, raycast does not work for me, and the OnMouseOver would not work, because the script has to be on the object that is getting OnMouseOver-ed, data transmission requires public variables, and you cannot have multiple public variables with the same name, which makes multiple units impossible. Therefore, I am now stuck. I have no ideas on how to make this work. Please help. Thank you.
Raycast are the way to go. Why didn't they work for you?
I don't really know. I think they are interfearing with On$$anonymous$$ouseOver, which is what I use for selecting my units.
They maybe interfering but I would abandon the On$$anonymous$$ouse Event. Raycast maybe slightly more difficult to work with but that is because they are more powerful.
Alright. Problem is: I have no idea on how to use raycasts. Youtube tutorials it is!
Your answer
![](https://koobas.hobune.stream/wayback/20220612094103im_/https://answers.unity.com/themes/thub/images/avi.jpg)