Search Unity

How to shake our camera?

Discussion in 'Scripting' started by kebaboom, Nov 8, 2006.

  1. kebaboom

    kebaboom

    Joined:
    Nov 2, 2006
    Posts:
    4
    Hello, I'm new here, I want to ask about how it is any possibilities to shake our camera/view? For example in FPS game like call of duty when the enemy shoot hit the player then the camera shake. Secondly, how to make our camera blur/motion blur effect?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Making the camera do motion blur would require the pro license.

    Making it shake, however, is easy. One way to do it:
    Code (csharp):
    1.  
    2. var shakeFactor = Quaternion.FromToRotation(Vector3.forward, Vector3(Random.Range(-1.0,1.0),Random.Range(-1.0,1.0), 10));
    3. CameraObject.rotation *= shakeFactor;
    4.  
    Someone will probably post a simpler way. I suck at Quaternions.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can also check out this topic for a script that might be useful.

    --Eric