Saturday, June 14, 2014

Camera Shake J# Unity3d

var camera : Camera;
var shake : float = 0;
var shakeAmount : float = 0.7;
var decreaseFactor : float = 1.0;

function Update() 
{
  if (shake > 0) 
  {
    Camera.transform.localPosition = Random.insideUnitSphere * shakeAmount;
    shake -= Time.deltaTime * decreaseFactor;
  } 
  else 
  {
    shake = 0.0;
  }
}

No comments:

Post a Comment

Popular Posts