Commit c0bac770 authored by Mahmoud Mostafa's avatar Mahmoud Mostafa

Added touch screen movement

parent 393db714
......@@ -15,6 +15,7 @@ namespace com.al_arcade.mcq
[SerializeField] private float laneSwitchSpeed = 8f;
[SerializeField] private float laneSwitchDuration = 0.25f;
[SerializeField] private float maxForwardSpeed = 7f;
[SerializeField] private float touchMovementSensitivity = 0.05f;
[Header("Visual")]
[SerializeField] private float bobAmplitude = 0.08f;
......@@ -141,6 +142,29 @@ namespace com.al_arcade.mcq
transform.rotation = Quaternion.Slerp(transform.rotation,
Quaternion.identity, Time.deltaTime * 8f);
}
// touch movement
if (Input.touchCount > 0)
{
print("touch detected");
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved)
{
float deltaX = touch.deltaPosition.x * touchMovementSensitivity;
Vector3 pos = transform.position;
pos.x = Mathf.Clamp(pos.x + deltaX, -6f, 6f);
transform.position = pos;
}
}
if (Input.GetMouseButton(0))
{
float deltaX = Input.GetAxis("Mouse X") * touchMovementSensitivity * 10f;
Vector3 pos = transform.position;
pos.x = Mathf.Clamp(pos.x + deltaX, -6f, 6f);
transform.position = pos;
}
}
private void HandleLaneInput()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment