|
I am getting some weird behaviour regarding raycasting. I have used this exact method of raycasting in two other places where it continues to have no problems. When the ray does hit, all the code executes fine and behaves as it should. I often will click the same thing more than once and eventually it will work. The problem is alot worse when I build and run the project. I have like a 50% chance of it working in the editor, and about a 5% chance working in game. It prints 'Something wrong with raycast' when it does fail.
Any ideas what could be wrong?
(comments are locked)
|
|
I'm not sure if this is what you are doing, but I noticed that my raycasts weren't working when I had two fingers on the screen. the problem was that I wasn't searching through all of the touches when checking if the raycast hit. I put my raycast inside of a foreach(touch) loop and solved the problem. This is inside of an update function, so it is being run every frame. I'll update the top with the full function.
Feb 07 '11 at 07:01 PM
James 12
(comments are locked)
|

Could you go into more detail about the collider(s) you are expecting to hit? It's acting like the ray isn't hitting anything, and your code as written assumes that it will never miss.
The collider i am expecting to hit is a cube that I instantiate from a prefab (box collider). What i am doing is dragging the cursor from a start cube. A line is drawn from there to the pointer. Then if you drop the line on any other cube it saves the connection in an array and lines are drawn to connect them. This ray (with the problem) is the one to detect if you are over a cube when you let go of the cursor. I use a ray for the first cube and it works every time.