- Home /
Question by
ChristianTobler · Apr 10, 2021 at 05:48 PM ·
2draycastmouseposition
Why is my raycast2D offset from the mouse position?
I am using:
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
When I click far outside of my collider on the right side, it registers a hit on the collider, but clicking on the collider itself also registers a hit. Clicking to the left of the collider does not seem to have the same effect.
I have reproduced this behavior in editor and on iOS.
We are using Unity 2019.4.18f1.
Thank you, and God bless you!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613032113im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why does my 2D raycast not always work? 1 Answer
2D - finding object at mouse position 2 Answers
Camera.ScreenToWorldPoint with Perspective camera 1 Answer
Multiple raycast not working? 0 Answers