- Home /
Fastest way to get sprite under finger?
I have a game that drops sprites and the user has to touch them to destroy them. I've noticed that using Physics2D.Raycast seems to miss some of the objects. Performance wise, what is the fastest way to get the object under your finger?
Answer by MTJR · Jan 02, 2015 at 06:25 PM
On touch devices i figured out that Input.MousePosition also works, so you can try to use the mouse position for a query:
if(Input.MousePosition == YourGameObject.transform.position)
{
Do anything
}
or you can also try the Input.getTouch(): Link to Unity API
Only a little idea i'm a beginner :-)
You wouldn't want to check the object position against the mouse position since one is in 3d and the other is 2D.
Your answer
Follow this Question
Related Questions
how to flip a sprite 0 Answers
mobile input / OnMouseDown / multi touch (most likely) 0 Answers
How to differentiate touches on mobile devices 1 Answer
Mobile GUI functionality & performance questions. 1 Answer
Adding Touch Controls to Car Game 1 Answer