Crash when using raycast to see if hit Game Object

In 2D the ray needs to travel across the plane and start outside of the shape for it to be regarded as a hit. Sending the ray from within the shape and then crossing outside of it would not be a hit. For your particular case, I would recommend you temporarily spawn a “touch” game object whenever you touch the screen and let that collide with whatever you are touching. I think this would be the simplest approach, and you also get a nice radius of the touch-object to reflect the width of your finger if you see what I mean.

If you just have a few interactive things with a simple sphere-like shape you would like to interact with, implementing it yourself in Lua seems perfectly reasonable to me as well. If their shapes are more complex, or there are many of them, the physics approach would be better.

An improvement we are going to make is to send response messages even when the rays miss, for both debugging and simpler logic. Can’t give you an ETA though, sorry about that.

2 Likes