add virtual phone
This commit is contained in:
19
Assets/PhoneRotator.cs
Normal file
19
Assets/PhoneRotator.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user