- Home /
Getting mouse coordinates on sprite
I am making a 2D program which a large (1000 x 793) sprite. How would I detect where on the sprite the mouse was clicked? I want it to give me the x and y coords when I click on the sprite. I can already detect when the sprite is clicked on, but there seems to be no way to get the point of click.
I thought at first to get the word coords, then convert it to the sprite, but it always seems to be off by around 96 pixels for some reason.
Answer by cjdev · Oct 21, 2015 at 05:36 AM
You could use Physics2D.Raycast to cast a ray onto the sprite from the mouse position like the example in this thread.
Your answer
Follow this Question
Related Questions
Mouse plane does not detect height 1 Answer
How do I drag a sprite around? 2 Answers
How to prevent GameObject from spawning on top of each other? 1 Answer
Why is OnDrag triggering but not OnMouseDown? 0 Answers
Check mouse click in front of object 0 Answers