Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by z7x9r0 · Sep 08, 2015 at 04:32 PM · 2djavascriptplatformerpixel

Has anyone made a successful Pixel Perfect Camera script for platformer games?

I've tried giving the asset store a try since I've been trying to figure out the logic myself, and the assets I tried all have not gotten this to work. I emailed the creators and they've been kind enough to email back with suggestions, yet my camera shakes when their scripts try to adjust the sprites to the screen resolution.

I have seen this blog mentioning how to do it manually, yet I'm making a mobile game, and the resolutions will change from device to device. Another issue is my camera is not static and moves so the sprites might not line up with the screen pixels as they should.

Any idea on how to get this to work? I've been wondering if anyone has gotten this to work and really wish this was a default feature in Unity.


Sample Project Folder in .zip file format if needed/wanted: https://www.dropbox.com/s/rp93y2yrj6f4tiz/SampleGame.zip?dl=0


Also the CameraScript.js Update function was supposed to be changed to LateUpdate to fix some camera shaking.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by hexagonius · Sep 08, 2015 at 08:42 PM

the default sprite renderer is capable of pixel snapping, so even if the camera sits at ,5 on any axis, the sprite will render correctly.

the camera orthographic size is half the screen height in Unity units. with sprites rendered with 100 pixels a Unit and let's say a screen resolution of 1024 * 768 results in an orthographic size of 3,84 (Screen.Height / 100 / 2). Let's call it design size you create your game for. for every device with a higher res, this will of course give a larger orthographic size, shrinking the content. The opposite is the case for lower res devices.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Losmath · Apr 27, 2016 at 01:29 PM

https://gist.github.com/pixelrevision/2981863

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

2D Platformer - Sidekick Follow Player 0 Answers

Change gravity on button 1 Answer

2D Platformer - How Do I Replicate Inputs And Delay Them? 1 Answer

I am having issues with my Jumping Script. 2 Answers

2D platform game stop camera from moving once reach end of screen 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges