|
I know there are a lot of mouse raycast questions, but most of them are in javascript and even when I find some answers in C# I still can't seem to solve my problem. So here it is: I am trying to click a 1 of 4 boxes with my mouse, all 4 boxes are named differently and have different tags. They all have a box collider, and what is suppose to happen is when I select one of them, it shows me which one is selected via an integer number 1-4. So here is the code:
(comments are locked)
|
|
When I do as you say, I don't get any errors initially but as soon as I hit play, the raycast doesn't work, and I get like 20-25 errors saying things like: ArgumentException: you are not allowed to call INTERNAL_CALL_ScreenPointToRay when declaring a variable UnityEngine.Camera:get_main() those 2 errors repeat pretty much, there are few small differences between them all but still I don't understand why that is. I also want to point out that this script is attached to the main camera, I don't know if that is an issue or not Unity is complaining because you are declaring a public variable and assigning a property or function result to it in the same instruction: You should only declare the variable, and assign the ScreenPointToRay in another instruction - in your case, it should be done inside Selection, since the ray must be based on the current mouse position: NOTE: Please only use the Your answer box to answer the question - use the minuscule add new comment button in the answer or question to post comments or replies.
Oct 12 '11 at 08:32 PM
aldonaletto
thank you very much
Oct 15 '11 at 06:34 PM
Ppa0
(comments are locked)
|
|
I'm not a C# expert, but it seems that you must write: And the declaration of the RaycastHit variable should be just:
(comments are locked)
|
