Question by
granatathiago · Jan 04, 2021 at 10:18 PM ·
movementmobiletouch controlstouchscreenmouse position
Problem with Swipe and rb.MovePosition
I'm trying to move my player by swiping / dragging, the swipe works fine, however if I tap in any part of the screen it teleports my character to that position. I have already tried using other methods to move it(like transform.translate or rb.velocity) but it doesn't feel fluid enough. So i'm a little bit lost in order to solve it, here is my code:
if (Input.GetMouseButton(0))
{
Vector2 curScreenPoint = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
Vector2 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint);
rb.MovePosition(curPosition);
}
Comment
Your answer
Follow this Question
Related Questions
how to differentiate touch and swipe 2 Answers
Touch screen not working on Android build? 0 Answers
How to assign a key to the button 0 Answers
Rotate object by touch using Angles? 0 Answers
Moving a ball left/right with buttons 0 Answers