下面是关于U3D摄像机的 抖动脚本

public class CameraShake : MonoBehaviour {
public Transform cameraTransform;
public float fRadio;
private Vector3 mCurrentPosition;
private float fShakeCD = 0.001f;
private int nShakeCount = 0;
private float fShakeTime;
public void setCameraShake()
{
if (cameraTransform == null) cameraTransform = transform;
mCurrentPosition = cameraTransform.position;
nShakeCount = Random.Range(5, 10);
Debug.Log(string.Format("nShakeCount= {0},fRadio = {1}",nShakeCount, fRadio));
}
void Update()
{
if (fShakeTime + fShakeCD < Time.time && nShakeCount > 0)
{
nShakeCount--;
float radio = Random.Range(-fRadio, fRadio);
if (nShakeCount == 1)
radio = 0;
fShakeTime = Time.time;
cameraTransform.position = mCurrentPosition + Vector3.one * radio;
}
}
}