Skip to content

Proof of Concept for a 2d camera that loops infinitely regardless of map size and aspect ratio

License

Notifications You must be signed in to change notification settings

Creighcl/UnityEndless2DPan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnityEndless2DPan

Proof of Concept for a 2d camera that loops infinitely regardless of map size and aspect ratio

Potential Improvements

  • Adjust for aspect ratio change mid-scene
  • Consolidate to one management script or a prefab
  • Add a swipe controlled Dolly
    • Add a 'sway' factor to lag behind camera rig's momentum

Hierarchy

  • Main Camera
    • TrailCamera
  • SceneLeftRoot !!y=0!!
    • Map background
      • SceneRightRoot !!y=0!!
    • <All GameObjects to exist "on" the map>

ScreenClipRight Script

Attached to the Main Camera. This script:

  • Identifies the map length by the distance between SceneLeftRoot and SceneRightRoot
  • Keeps the TrailCamera a set distance away from the primary camera
  • Jumps the main camera to the rightmost and leftmost boundaries when needed

OrientLeft Script

Attached to the SceneLeftRoot object. This script:

  • OnStart() Adjusts the SceneLeftRoot position to be the starting leftmost position on Camera

Purpose: By dynamically positioning the root onStart(), we account for all aspect ratios

SpinObjectByXPosition

Attached to the Main Camera for no particular reason. Just needs access to calculate or ask for Map Length. This script:

  • Has a "SpinningRoot" game object that you give it
  • Will rotate assigned object based on current camera position:
    • Starting position is 0° rotation
    • Quarterway through the map is 90° rotation
    • Halfway point is 180° rotation
    • etc

License

This is just a Proof on concept project, sharing if it helps anyone. See the license file for license rights and limitations (MIT).

About

Proof of Concept for a 2d camera that loops infinitely regardless of map size and aspect ratio

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages