How can I make the player follow my touch?
Hello guys!
So I have a problem. I'm trying to make a game like Rolling Sky. I have everything i need and I just need to get the Player Movement to work but I can't seem to figure out how... I searched all over the Internet and none of the suggested solutions work.
In my game the Camera follows the Player and the Player follows the finger. In my Code the touch position gets translated into world coords... But the problem is that the camera is following the player, so the movement doesn't work properly. It's just unplayable like this... So here is the code I use:
void Update()
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
Vector3 touchPos = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
Vector3 targetPos = new Vector3(touchPos.x, transform.position.y, transform.position.z);
transform.position = Vector3.Lerp(transform.position, targetPos, speed);
}
}
I hope someone can help me figure this out. I'm thankful for every advice :)
Your answer
Follow this Question
Related Questions
Free 3d Camera rotation around a 3d object with touch inputs. 0 Answers
Help with touch button (can't call a function) 0 Answers
Is it possible to detect touch In a certain GUI element? 1 Answer
Make touch drag more intuitive/smooth for AR-Application 0 Answers
How to hide and show level based on player/camera position? 0 Answers