I am a beginner in this field I know about keyboard inputs but I have no idea in touch inputs in first person character controller , I have searched in YouTube but I am not satisfied and can't able to understand!!
The code is provided below help me please!!
using System.Collections;
using System.Collections.Generic;
using Unity.Android.Gradle.Manifest;
using Unity.VisualScripting;
using UnityEngine;
public class camerarotation : MonoBehaviour
{
new public Transform camera;
public float mousesensitivity;
public Transform player;
float Xrotation;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.None;
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mousesensitivity;
float mouseY = Input.GetAxis("Mouse Y") * mousesensitivity;
if (Input.GetMouseButton(2))
{
player.Rotate(Vector3.up * mouseX);
}
if (Input.GetMouseButton(2))
{
Xrotation -= mouseY;
Xrotation = Mathf.Clamp(Xrotation, -85f, 85f);
camera.localRotation = Quaternion.Euler(Xrotation, 0f, 0f);
}
}
}