You don't show (or even say) what the reported error is - that'd be helpful...
While I haven't tried this, the
Raycasting docs seem fairly clear here:
First, only the first 2 args (the 2
Vector2 args) are required in the
IntersectRay call. That 3rd arg is an exclusion array, which defines objects that the ray could collide with, but you're not interested in knowing about.
The syntax you show for that 3rd arg looks correct, so I can only assume that maybe the object with the script (the one represented by
this) isn't a type of collision object?
It sounds like that's necessary from the docs.
So, I'd recommend a few things:
- See if it works without the 3rd
exclusion array arg
- If you need that 3rd arg, make sure the script is attached to a collision object
- If you're still struggling, post the actual error you're seeing