• 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 /
  • Help Room /
This question was closed Nov 11, 2019 at 12:34 AM by Le-Pampelmuse for the following reason:

The question is most likely answered (comment voted up by OP but no response from them)

avatar image
Question by rivascarlosva · Nov 03, 2019 at 05:41 AM · 2dgameobjectmobile devices

How to make object fall in the same amount of time no matter screen height?

I am developing a 2D Mobile game, and part of it requires an object to fall from the top of the screen to the bottom. I want the game to be equal among all screen heights, so how could I make my game object fall from the top of the screen to the bottom in the same amount of time no matter how tall a phone’s screen is?

Comment

People who like this

0 Show 0
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

  • Sort: 
avatar image
Best Answer

Answer by Le-Pampelmuse · Nov 03, 2019 at 04:41 PM

Without having proper details about the specific mechanics involved in your game, I would suggest using a animation for the falling object.

Since animations run at set speeds, using their own frames per second settings, you could have either a million complicated keyframes per second or just 2 simple position keyframes per second, both would take one second to play.

That would, in my opinion, be the easiest way to ensure consistent fall time across all phones or screen resolutions without any calculations.

Comment

People who like this

0 Show 0 · 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

Answer by xxmariofer · Nov 04, 2019 at 03:12 PM

there are 2 options, what i tend to use is a script that uses a fixed height/width in all my games across all devices, or simply set both objects to be at the border of the screen, using the Screen.height parameter, and use the Vector3.lerp so that both objects reach the desired position in the desired time, if you need help with any of the solutions just ask me

Comment

People who like this

0 Show 4 · 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 Le-Pampelmuse · Nov 11, 2019 at 12:32 AM 0
Share

I don't think any of those suggestions will solve the OP's stated problem:

How could I make my game object fall from the top of the screen to the bottom in the same amount of time no matter how tall a phone’s screen is?

It is still unclear if OP meant just the different screen resolutions of phones or the actual screen sizes. I interpreted it as the second option, hence why I suggested using an animation.

Since the OP has not responded to my comment, but actually did vote it up, I'm converting my comment to an answer and closing the question as accepted, since it seems that it solved their problem.

avatar image xxmariofer Le-Pampelmuse · Nov 11, 2019 at 07:23 AM 0
Share

"the actual screen sizes" will allways depend on the screen resolutions. it is imposible my suggestions doesnt fix his issues, if you consider your answer to be right just because he upvoted is all fine (altough i cant see any upvote), but your answer is not a better solution than mine and is imposible that my answer doesnt fix his question. you are suggesting using unity animations, and all animation engines use lerping for position transpolation.

avatar image Le-Pampelmuse xxmariofer · Nov 12, 2019 at 01:29 AM 0
Share

Hi.

"the actual screen sizes" will allways depend on the screen resolutions.
That's incorrect. The real world screen size is completely independent from the Screen.height in pixels.

My Sony smartphone has a 4K screen height of 12 cm, it's Screen.height == 3,840‬.

My Samsung FULL HD monitor has a screen height of 39.8 cm it's Screen.height == 1080

A gigantic screen on a baseball field might have an even lower resolution, but is 10 meters high.


but your answer is not a better solution than mine...
That's a subjective opinion and completely fine.

..and is imposible that my answer doesnt fix his question
That's not really for you to decide, is it? ;)

if you consider your answer to be right just because he upvoted is all fine (altough i cant see any upvote)
You can very easily visit the OP's page and see their last activities. You can't see the upvote here because I initially posted it as a comment, because it was just a suggestion based on incomplete informations, and later converted it into an answer. As a comment, it had an upvote from the OP. Now that you mention it, that IS weird. Another bug in the Answers platform.

you are suggesting using unity animations, and all animation engines use lerping for position transpolation.
It might be that many animation implementations use inter-polating to smooth out between positions, but using Vector.Lerp is discouraged for controlling general movement, unless in very special cases, because every since it existed, people using Unity constantly used it wrong and in connection with Time.deltatime. That's a failure prone and inaccurate way to move things.
I don't claim that you intended to suggest using it this way, but since you didn't eleborate any further in your answer, I chose to point out that the way it is commonly used, won't work here. Maybe I should have added this paragraph to my initial comment on your answer to avoid confusion, sorry.

However, as I stated in my comment-turned-answer, using the animation system is just the easiest way (for the scope of the OP's application) without involving any additional calculations like coding. I did't claim it was the only way. ;)

Greetings.

Show more comments

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

275 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 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 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 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

Changed the hitbox for my aim, but the game is still centered the gun at the old hitbox. 0 Answers

Unity2D, place GameObject at the top of another GameObject 0 Answers

2D gameobjects only showing Sprite! 0 Answers

Select Object And Spawn it 1 Answer

My collider2D don't work 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