Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 chiazam · Jul 08, 2020 at 11:25 PM · transform.positiontime.deltatime

Would i need Time.deltaTime if am just incrementing transform.position

 //this function would set the ScaleToLeft function, when this object size is not less than the referenceSize variable
     private void ResetScaleToLeft()
     {
         //Calls teh scale rate function that sets the scale rate value
         SetScaleRate();
         //holds teh size of the object before its scaled
         previousSize = this.GetComponent<SpriteRenderer>().bounds.size.x;
         //Reset Scale of the object
         transform.localScale = new Vector3(RoundUpResetValue(), transform.localScale.y, transform.localScale.z);
         //holds the new Size of the object after its scaled
         newSize = this.GetComponent<SpriteRenderer>().bounds.size.x;
         //Calls this functions
         NewObjectPositionToLeft();
     }
 
     //this fucntion would set the new X position to the left
     private void NewObjectPositionToLeft()
     {
         float offset;
         float newSizeDifference;
         float previousSizeDifference;
 
         //Calculating the new Size difference
         newSizeDifference = (newSize - originalSize) / 2;
         //Calculatig the previous Size difference
         previousSizeDifference = (previousSize - originalSize) / 2;
         //Calcuates the difference between the new size difference and previous size difference
         offset = newSizeDifference - previousSizeDifference;
         transform.position = new Vector3(transform.position.x - offset  , transform.position.y, transform.position.z);
 
 
     }
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 tuinal · Jul 09, 2020 at 01:04 AM

The reason to multiply by delta time is if you're updating per frame; if you don't, then the rate the object moves at will vary with framerate, which is bad/inconsistent behaviour.

If you're not updating per-frame (impossible to tell from the code when the methods are called), but in response to an event (e.g. moving something instantly 4 units left when clicked), then you don't need to multiply by delta time.

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 chiazam · Jul 09, 2020 at 06:03 AM 0
Share

Thank you very much for your reply,

Am sorry that my code isn't very readable , i would work on that. The ResetScaleToLeft() is called from the Update Function when a boolean variable = true. When the ResetScalToLeft() function is done executing , it then calls the NewObjectPositionToLeft(). The NewObjectPositionToLeft() function is where an using transform.position.

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

133 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

Related Questions

How to fix box drop via code animation? 2 Answers

Transform player to RaycastHit.point depending on speed float 1 Answer

moving objects with transform position 2 Answers

2D - Move an object 1 Answer

Using time.deltatime to move from coordinate to coordinate is too fast? 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