Giter VIP home page Giter VIP logo

unity3d-perlincamerashake's Introduction

Perlin Camera Shake component for Unity3D

Just a camera shake MonoBehaviour script that you can attach to a Camera as a component in Unity3D. I guess it can be ideal if you just need camera shake, and would rather not use the full Cinemachine package.

Main feature: It's not crappy code

  • It doesn't do any polling. If you add 'trauma', it starts a coroutine that processes the trauma, and then exits.
  • Doesn't keep 'lerping' indefinitely.
  • Generally only executes what is strictly necessary for the given settings, e.g.:
    • If you set only rotational shaking, it won't bother calculating translation.
    • If you only ask for X axis translation, it won't calculate things for the other axes.

Overall it should be performant. Not that it matters a lot probably, but still. ;)

Prerequisites

  • Your Camera should be parented to another GameObject, and that GameObject should be moved, if your game requires a moving camera. But this is how we normally use cameras in Unity. However, the script does support non-zero initial camera positions and rotations.

Usage

  • Copy the .cs file to your Assets folder.
  • Add the component to your Camera.
  • Set the settings in the Inspector pane, and test it by manually adding some trauma.

Obviously, you'll need to add 'trauma' during runtime to initiate the camera shake. You can do this by directly accessing the public Trauma property of the component. I used it with my own event system instead, but I commented out the event-related lines. Feel free to remove these if you're not gonna use any event system.

Settings

You can customize the following parameters of the Perlin noise based camera shake in the Inspector:

Editor customization options of the Perlin Camera Shake component

Bugs

Hopefully none. If you happen to find any, let me know, and I'll fix them.

Copyrights

Do whatever you want. ¯\_(ツ)_/¯ It's just 300 lines of code.

Sources/inspirations

unity3d-perlincamerashake's People

Contributors

baratgabor avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.