Last active
September 10, 2024 07:36
-
-
Save GOROman/51ee32887bd1d3248b7610f845904b30 to your computer and use it in GitHub Desktop.
Unityで微細眼球運動っぽい何か
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class EyeJitter : MonoBehaviour { | |
float timer = 0.0f; | |
Quaternion rot; | |
public float changeTime = 0.4f; // 変更する時間最小値 | |
public float changeTimeRange = 2.0f; // 変更する時間幅(乱数) | |
public Vector2 range = new Vector2(0.001f, 0.03f); // 可動範囲 | |
public Transform rightEye; // ex.) 93.!joint_RightEye | |
public Transform leftEye; // ex.) 95.!joint_LeftEye | |
void Start () { | |
} | |
void LateUpdate () { | |
timer -= Time.deltaTime; | |
if ( timer <= 0.0f ) { | |
timer += Random.Range(changeTime, changeTimeRange); | |
Vector3 v = Vector3.zero; | |
v.x = Random.Range(-range.x, +range.x); | |
v.y = Random.Range(-range.y, +range.y); | |
rot = Quaternion.EulerRotation(v); | |
} | |
leftEye.localRotation *= rot; | |
rightEye.localRotation *= rot; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
そもそも、左右の目は同時に動くのか?