Skip to content

Instantly share code, notes, and snippets.

@nkjzm
Forked from GOROman/EyeJitter.cs
Created December 6, 2018 17:58
Show Gist options
  • Save nkjzm/d11c8478d2bfdb03e936396226715f04 to your computer and use it in GitHub Desktop.
Save nkjzm/d11c8478d2bfdb03e936396226715f04 to your computer and use it in GitHub Desktop.
Unityで微細眼球運動っぽい何か
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