20 lines
559 B
C#
20 lines
559 B
C#
using Unity.Mathematics;
|
|
using UnityEngine;
|
|
|
|
public class PhoneRotator : MonoBehaviour
|
|
{
|
|
Quaternion initialRotation;
|
|
public float swingRange = 30f; // In Degrees
|
|
public float speed = 2f;
|
|
void Start()
|
|
{
|
|
initialRotation = GetComponent<Transform>().localRotation;
|
|
}
|
|
void Update()
|
|
{
|
|
float currentDegrees = Mathf.Sin(Time.time * speed) * swingRange;
|
|
Quaternion swingRotation = Quaternion.Euler(0, 0, currentDegrees);
|
|
GetComponent<Transform>().localRotation = initialRotation * swingRotation;
|
|
}
|
|
}
|