Coder Social home page Coder Social logo

vuthysruy / unity-prerendered-bg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cazsaragih/unity-prerendered-bg

0.0 0.0 0.0 106 KB

A sample Unity project to handle camera movement on pre-rendered background games. The technique is known as 'Ken Burns' effect.

C# 96.04% ShaderLab 3.96%

unity-prerendered-bg's Introduction

Pre-Rendered Background in Unity

A sample Unity project to handle camera movement on pre-rendered background games, also known as 'Ken Burns' effect.

Specification

  • Unity 2019.4
  • Any modern version, really (5.0+)

How to Play

  • Open Main scene
  • Use WASD to move the character around

Setup

Camera

There are 2 cameras in the scene. One is the main camera, responsible for what you see. The other is used to convert character's world position to screen point.

float playerOnScreenPosX = secondaryCamera.WorldToScreenPoint(playerTransform.position).x / Screen.width;
float playerOnScreenPosY = secondaryCamera.WorldToScreenPoint(playerTransform.position).y / Screen.height;

Min/MaxCamOffset: The min/max offset the camera can pan. The value can be simulated by ticking IsDebug value on the inspector then tweak the X and Y value.

Min/MaxScreenPoint: The min/max character's position in screen point. How far you allow your character to be on the edge of the screen is the value you put on these variables. Start by ticking IsDebug and see the value of PlayerScreenPos.

These variables are important to track the character's movement. By predefining the value of CamOffset and ScreenPoint, we can then calculate character's screen point relative to the cam offset and pan accordingly.

Invisible Object

3D object on the scene needs to be invisible while still maintaining its collider. To achieve this, use special material called InvisibleMat on the obscuring object and attach Obscurable component to the obscured object.

unity-prerendered-bg's People

Contributors

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