- Home /
Question by
drz01311 · Sep 07, 2021 at 01:09 PM ·
mobiletouchtouch controls
How to make touch controls similar to Bumper.io
Hello,
I am trying to put touch controls similar to bumper.io in my game.
I have figured out how to make the player move the direction it is facing, so that is not an issue.
Here is my code although it has 2 major problems that I have found:
private void FixedUpdate()
{
if (Input.touchCount > 0)
{
Vector3 touchPos = Input.GetTouch(0).position;
touchPos.z = 10.0f;
touchPos = mainCamera.ScreenToWorldPoint(touchPos);
transform.LookAt(new Vector3 (touchPos.x,0,touchPos.z));
}
transform.Translate(Vector3.forward * Time.deltaTime, Space.Self);
}
Problem 1: Once the player actually reaches the real world point of the touch, then it glitches out.
Problem 2: In bumper.io you can move your finger around in circles and the player will go around in circles too. You can do this anywhere onscreen, not just around the actual player in game. In my game the player just moves towards the real world point of the finger, and doesn't do circles.
If anyone is able to help or even point me in the right direction, it would be greatly appreciated.
Comment