Drag a sprite from anywhere in the screen
Hey, i am trying to make a sprite dragged from whenever i touch in the screen, i don't mean that when i touch the sprite will go to my touch position and start drag from there. What i mean is that if the sprite is at the bottom of the screen and i am draging my finger on the top of the screen the sprite will go from its place relatively to how i moved my finger but will behave like i dragged it from its position and will not "jump" to my finger touch position.
Answer by eses · Aug 21, 2018 at 02:01 PM
Hi @orizvida
You should read first about Unity touch detection options. See documentation: https://docs.unity3d.com/ScriptReference/Input.GetTouch.html
https://docs.unity3d.com/ScriptReference/Touch-phase.html
Touch detection itself using Input system is not dependent on hitting any particular object.
Detect your touch, then move your object. See above links. There it is explained, how you can calculate the offset/delta of touch.
Your answer
Follow this Question
Related Questions
What is the best way to implement a more responsive custom drag event with Scroll Rect? 0 Answers
Code help with mobile touch drag 3D Top Down 0 Answers
Unity script opens Windows Explorer. Why? 1 Answer
What to code if the laboratory equipments are correct and then proceeds to the next scene? 0 Answers
Touch to move and drag to rotate object 2 Answers