Skip to content

Instantly share code, notes, and snippets.

@GOROman
Last active November 25, 2022 12:17
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save GOROman/51ee32887bd1d3248b7610f845904b30 to your computer and use it in GitHub Desktop.
Save GOROman/51ee32887bd1d3248b7610f845904b30 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;
}
}
@GOROman
Copy link
Author

GOROman commented Nov 5, 2016

そもそも、左右の目は同時に動くのか?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment