UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"rotate 3D object by touch, only horizontal rotation"
using UnityEngine; public class RotateObject : MonoBehaviour { private float rotationSpeed = 0.2f; private Vector3 touchPosition; private Quaternion rotationY; void Update() { if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved) { touchPosition = Input.GetTouch(0).deltaPosition; rotationY = Quaternion.Euler(0f, -touchPosition.x * rotationSpeed, 0f); transform.rotation *= rotationY; } } }