Initial commit

This commit is contained in:
Savina Rizdafayi
2025-07-12 19:53:40 +07:00
commit d7120c397a
933 changed files with 246809 additions and 0 deletions

View File

@ -0,0 +1,48 @@
using UnityEngine;
public class GyroKepala : MonoBehaviour
{
private Gyroscope gyro;
private bool gyroEnabled;
// Koreksi rotasi agar sesuai dengan orientasi Unity
private Quaternion rotationFix = Quaternion.Euler(90f, 0f, -90f);
void Start()
{
Screen.sleepTimeout = SleepTimeout.NeverSleep;
gyroEnabled = EnableGyro();
}
private bool EnableGyro()
{
if (SystemInfo.supportsGyroscope)
{
gyro = Input.gyro;
gyro.enabled = true;
Debug.Log("✅ Gyroscope enabled");
return true;
}
else
{
Debug.LogWarning("❌ Gyroscope not supported on this device.");
return false;
}
}
void Update()
{
if (!gyroEnabled) return;
Quaternion deviceRotation = gyro.attitude;
// Koreksi rotasi dari koordinat perangkat ke Unity
Quaternion correctedRotation = new Quaternion(
deviceRotation.x,
deviceRotation.y,
-deviceRotation.z,
-deviceRotation.w
);
transform.localRotation = rotationFix * correctedRotation;
}
}