Git Product home page Git Product logo

camerakit2d's Introduction

CameraKit2D

CameraKit2D is a 2D camera framework for Unity. This was originally going to be an implementation of the fantastic vocubulary that Itay Karen introduced in his GDC talk (more info available here). After a couple weeks of development the realization that you can't make a great camera system entirely generically was found. Games and cameras are just too specific to have a drop-in, perfect solution. Rather than settle for just a good solution CameraKit2D was made into a base framework that is very easy to add your own behaviors to.

Several components are provided out of the box so you can get up and running quickly and with good examples to make your own behaviors and effectors from. Three different smoothing methods are also provided (smooth damp, spring and lerp).

Base Camera Behaviors (ICameraBaseBehavior)

Base camera behaviors are the main controllers of your camera. Included with CameraKit2D in the initial release are the following: Camera Window (vertical, horizontal or both), Dual Forward Focus (direction, threshold or velocity based) and Position Locking (vertical, horizontal or both). They all include Gizmos in the editor so you can visualize how they work. Use these classes as a base to make your own behviors. The only requirement is that you implement the ICameraBaseBehavior interface.

Any Base Camera Behaviors that are components on the same GameObject as the CameraKit2D script will automatically be added in Awake. You can add and remove base camera behaviors at runtime via the addCameraBaseBehavior and removeCameraBaseBehavior methods. There can be more than one base behavior affecting a camera at any time. This lets you have separate behaviors for horizontal and vertical camera positioning for example.

Here are some examples of the included base behaviors: camera behaviors

Effectors (ICameraEffector)

Effectors let you modify the base camera behavior. These allow you to augment your camera most often based on a specific region in your level. There can be more than one effector active at any time. Effectors also provide a weight which is used to position the camera. Higher weights mean that the effector has more influence on the camera. The Cue Focus Ring effector is included as an example. It is a single or dual ring circular trigger that pulls the camera towards it's center when the player enters. An AnimationCurve is used to modify how much the camera is pulled towards the center.

Creating your own effectors only requires implementing the ICameraEffector interface. You can then add and remove your effectors at runtime as needed via the addCameraEffector and removeCameraEffector methods.

Finalizers (ICameraFinalizer)

Finalizers provide a last ditch chance to fully modify the camera position. Unlink base behaviors and effectors finalizers are not weighted. The finalizers are passed the desired position that the base behaviors and effectors calculated. The main use cases for finalizers are hard lines like map bounds (see MapExtentsFinalizer for that one) or constraining movement to a region.

CameraKit2D Flow

Flow chart

The final result of the base behaviors and the effectors is then passed on to the finalizers.

License

Attribution-NonCommercial-ShareAlike 3.0 Unported with simple explanation with the attribution clause waived. You are free to use CameraKit2D in any and all games that you make. You cannot sell CameraKit2D directly or as part of a larger game asset.

camerakit2d's People

Contributors

prime31 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.