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 sn24 · Jul 18, 2017 at 11:56 AM · rigidbody2dvelocityscreen resolutionscreensize

Rigidbody2D velocity relative to screen size

Hey all I am having a problem with velocities. When I view the velocity in small resolution, it appears fast but when I see it in full screen, it appears slower. I know that it just appears to be so but I don't even want it to appear so. Any ideas how to make it appear same in all resolutions? Please Help!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tony-Tonijn · Jul 18, 2017 at 12:39 PM

Depending on what camera you're using (I've assumed orthographic as you are using 2D rigidbodies) you would just use a scalar and the orthographic size of the camera to determine the increase in speed.

 rigidbody2D.velocity *= someCamera.orthographicSize * someScalar;

However this might become a lot more complex if you are using a perspective camera. In that case you need to account for both the size of the FOV and the distance to the object. Here you would probably want to measure the bounding box of the object you want to display against the size of the screen in pixels. You can find the later two in Screen.width and Screen.height.

I hope this answers your question somewhat.

Comment
Add comment · Show 6 · 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 sn24 · Jul 18, 2017 at 12:49 PM 0
Share

$$anonymous$$ine is an orthographic camera.

avatar image sn24 · Jul 18, 2017 at 12:50 PM 0
Share

Can you please explain what is a scalar? I am a newbie in unity so i don't know many terms sorry.

avatar image sn24 · Jul 18, 2017 at 12:51 PM 0
Share

Orthographic size of the camera is 5. Can you please help me with a few lines of code for accomplishing what you are saying?

avatar image NoseKills · Jul 18, 2017 at 03:44 PM 0
Share

Scalar just means a number basically.

What is is it that you actually want?

For the object to move the same amount of pixels/second or same amount of real world millimeters/second or something else?

Depending on the answer you'll have to know at least the resolution and maybe the dpi or physical size of the screen.

Then depending on whether you want just the speeds or also object sizes to scale, use the scalar to resize the camera and/or the game objects. If you change object sizes, they'll move at different speed in relation to their size on different sized screens.

The problem seems kind of weird and there shouldn't be a reason for having to do this 99% of time so it might be useful to try to describe the root of the problem (for example from player's point of view) and wanted end result a bit more.

avatar image sn24 · Jul 19, 2017 at 10:33 AM 0
Share

I want the object to become larger and the speed to basically increase by the same amount the screen size is increasing (keep the velocity constant relative to the screen size) so as to make it appear same in all screen sizes.

avatar image NoseKills sn24 · Jul 19, 2017 at 03:19 PM 0
Share

Please post comments as comments, not answers. I converted this one.

Unity already does things like this. If you use an orthographic camera with orthographic size of 5 for example, it means the visible game area on any screen is 2x5 units high from bottom of screen to top of screen. Also a sphere with a 1 unit diameter will be 1/10 of the screen height on any device.

The physics engine uses those same game world units to do its calculations so for example an object moving 1 units per second upwards will take 10 seconds to travel from bottom of screen to top of screen on any device if the game's orthographic camera has a size of 5.

The aspect ratio of the device deter$$anonymous$$es how many game world units are visible width-wise (orthographic camera). Similar rules apply when using perspective camera.

If you scale objects, it will change how the game plays because they will now collide more often or less often. If you change camera settings, it will change gameplay because it changes when objects enter and exit the screen

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

69 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Moving game object have different speeds in different screen resolutions and it's jittering 1 Answer

Scaling an object causes slow movement (Since Update 5.5.4) 1 Answer

,Rotate a gameobject around another while being attracted by its gravity 1 Answer

Modifying a kinematic rigidbody2D.velocity makes player to go through the wall 0 Answers

rigidbody2D maximum y velocity 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