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 /
  • Help Room /
avatar image
0
Question by XregularC · Jul 22, 2016 at 10:04 AM · c#speedmove an objectscreen sizewindowed

Is it possible to set a GameObjects moving speed depending on the size of the game window/screen resolution?

To be more specific I have a GameObject with a script attached to it. The script moves the GameObject with transform.translate. It always moves the same speed but I don't want that. I want it to take the same amount of time to go from the bottom of the game window to the top of the game window no matter the size of the game window. Currently if the game window is large the GameObject appears to be moving slowly and if the game window is small the GameObject appears to be moving more quickly.

Comment
Add comment · Show 2
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 NoseKills · Jul 22, 2016 at 02:31 PM 0
Share

Anything is possible but it sounds strange that you'd want to go about fixing the issue that way. If you change the objects speed, then it will be moving slower in proportion to its own size and it will again look and feel pretty different on different resolutions.

How are you moving the object? Is it a UI object or something in world space? Orthographic or perspective camera?

Usually all you need to do is change your camera's FOV or orthographicSize based on the screen aspect ratio: that way your screen height will always be x units in world space, your object will stay the same size in relation to its speed and screen size and thus it will take the same amount of time for it to travel x units.

avatar image XregularC NoseKills · Jul 22, 2016 at 04:14 PM 0
Share

Thanks for the response. Yeah it's an UI element I'm trying to move. It's actually the credits text which goes from the bottom of the screen and up. Because it's part of a canvas and I've set the canvas to scale with screen size the text is the appropriate size. I added a script to the UI text GameObject which makes the text move, it used transform.translate to do so. The speed is the same no matter the size of the screen/game window. This makes it feel like the text is moving faster or slower than what I want it too. I could most likely use math to make it go the appropriate speed if only I could get the size of the game windows specifically. I tried using the Screen class but either I don't understand how to use it properly or it takes the width and height of the screen itself, not the game window.

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by TheShadyColombian · Jul 22, 2016 at 06:23 PM

use Screen.currentResolution to get the screen resolution in a sort of weird vector2 format ( so Screen.currentResolution.height for the height instead of Screen.currentResolution.y. Weird, I know);

Comment
Add comment · Show 1 · 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 XregularC · Jul 22, 2016 at 07:34 PM 0
Share

Ah yes thank you very much. This seems to work. I already tried using the Screen class but I didn't know about Screen.currentResolution. Either way now it works as intended :)

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

202 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

Related Questions

How to keep moving an object only with its speed? 0 Answers

Speed of the script 1 Answer

Stop moving gameObject and push it back 0 Answers

What is the best/easiest method to scale a 2D mobile game to all screen sizes? 0 Answers

How to change Animator speed with the state name 0 Answers


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