40 lines
829 B
C#
40 lines
829 B
C#
using UnityEngine;
|
|
|
|
public class CameraShake : MonoBehaviour
|
|
{
|
|
private Transform myTransform;
|
|
|
|
private Vector3 initPos;
|
|
|
|
public float bigRadius = 3f;
|
|
|
|
public float bigSpeed = 0.5f;
|
|
|
|
public float smallRadius = 0.5f;
|
|
|
|
public float smallSpeed = 2f;
|
|
|
|
private Noise noiseBigX;
|
|
|
|
private Noise noiseBigY;
|
|
|
|
private Noise noiseSmallX;
|
|
|
|
private Noise noiseSmallY;
|
|
|
|
private void Start()
|
|
{
|
|
myTransform = base.transform;
|
|
initPos = myTransform.position;
|
|
noiseBigX = new Noise(bigSpeed);
|
|
noiseBigY = new Noise(bigSpeed);
|
|
noiseSmallX = new Noise(smallSpeed);
|
|
noiseSmallY = new Noise(smallSpeed);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
myTransform.position = initPos + new Vector3(noiseBigX.Update() * bigRadius + noiseSmallX.Update() * smallRadius, noiseBigY.Update() * bigRadius + noiseSmallY.Update() * smallRadius, 0f);
|
|
}
|
|
}
|