- Home /
Camera.ScreenToWorldPoint with Perspective camera
Hey guys,
I've got a 2D scene with a camera with perspective projection. I'm translating the mouse position into the scene to hover over some objects. My problem is that whenever I change the mouse positions z axis which is neccessary to not get the camera position, the ray has some offset to its real position, depending on the screen resolution, which is obviously caused by the perspective camera. How can I fix this? Thanks in advance
Answer by Ziya · Jul 29, 2017 at 03:38 PM
I recommend checking out Camera.ScreenPointToRay. Another option is Camera.orthographic.
@Ziya The problem with ScreenPointToRay() is that a click draws my line renderer from the transform to the mouse position, so I have to get the WorldPosition. Is there another way to archieve this?
Your answer
Follow this Question
Related Questions
Wrong world point mouse position 1 Answer
ScreenToWorldPoint question 1 Answer
Camera ScreenToWorldPoint Instatiating 1 Answer
2D - finding object at mouse position 2 Answers