I would like to have a constant yet mild shake on my Main Camera, since the level in question is an engine room level so it makes sense for the camera to shake a little bit all the time. This script works but it impedes my camera movement script. I need my cam to move as well as shake constantly, heres the script:
public Transform camTransform;
// How long the object should shake for.
public float shake = 0f;
// Amplitude of the shake. A larger value shakes the camera harder.
public float shakeAmount = 0.7f;
public float decreaseFactor = 1.0f;
Vector3 originalPos;
void Awake()
{
if (camTransform == null)
{
camTransform = GetComponent(typeof(Transform)) as Transform;
}
}
void OnEnable()
{
originalPos = camTransform.localPosition;
}
void Update()
{
if (shake > 0)
{
camTransform.localPosition = originalPos + Random.insideUnitSphere * shakeAmount;
shake -= Time.deltaTime * decreaseFactor;
}
else
{
shake = 0f;
camTransform.localPosition = originalPos;
}
}
}
The second thing Id love to have is an OnMouseDown camera shake. I can find lots of help regarding on collision shake but I need my camera to shake a lot more then the mild constant shake when specific objects are clicked, anyone Know or have a script to do that without impeding on other camera movement scripts?