- Home /
Question by
Denscrivent · Sep 07, 2017 at 03:55 AM ·
collider2dspriterendererphysics2d.raycast
Raycast2D Hit Other Object
Hi, I'm developing a 2D game using Physics2DRaycaster component in main camera, and I use Event Triggers to interact with objects.
the objects marked with red circle are objects(books, vase, pillow) that can be dragged using event triggers (BeginDrag, Drag, EndDrag). the blue rectangle is the object(RoomController) I use to switch rooms (left or right) also using event triggers (BeginDrag, Drag, EndDrag).
The problem is, sometimes the raycast only hit the RoomController instead of the objects, hence making it swipe room instead of picking objects.
Please help.
a.png
(100.7 kB)
Comment
Best Answer
Answer by Denscrivent · Sep 07, 2017 at 05:00 AM
I've found the solution. I move the object's z position forward towards the camera and it works perfectly