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
1
Question by Loius · Oct 26, 2012 at 02:50 PM · timesmoothdamp

Why is my SmoothDamp taking four times longer to finish than it should?

This takes 4.6 seconds to complete. I want it to take 1.0 seconds - like I put in the function.

cur, to, and vel are not altered anywhere.

What have I done wrong?

 #pragma strict
 
 var from : float;
 var to : float = 10;
 var time : float = 1;
 private var vel : float;
 private var cur : float;
 private var amntTime : float;
 
 function Start () {
     cur = from;
     vel = 0;
 }
 
 function Update () {
     amntTime += Time.deltaTime;
     cur = Mathf.SmoothDamp(cur,to,vel,time);
 
     if ( Mathf.Abs(cur-to) < 0.01 ) {
         Debug.Log("Took " + amntTime);
         gameObject.active = false;
     }
 }


I was using deltaTime, which has the same results as this convoluted thing. Just trying to see if somehow the coroutine was getting the wrong deltaTime.

Comment
Add comment · Show 7
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 hvilela · Oct 26, 2012 at 11:30 PM 0
Share

"vel" is zero when you first call the function?

avatar image Loius · Oct 27, 2012 at 04:50 AM 0
Share

Right, it is. It's a consistent ratio of time taken - if I tell it to take one second, it takes 4.6; if I tell it to take 0.25 seconds, it takes 1.~ seconds. It's about 4x longer than it should. It seems hilarious to me but I also wanna make it work.

This is running in a static coroutine (object.StartCoroutine(staticFunction()), if that matters.

avatar image whydoidoit · Oct 27, 2012 at 05:16 AM 0
Share

I've always considered that time to be nothing to do with seconds! It says in the doc "approximate time" - never seemed particularly relevant to the time in seconds to me.

avatar image hvilela · Oct 27, 2012 at 05:26 AM 0
Share

It says approximate cause it's no precise. It can't justify an 4x difference.

avatar image whydoidoit · Oct 27, 2012 at 08:34 AM 0
Share

Or perhaps because the documentation author didn't understand what algorithm was being used - given the docs are very poor in some places I wouldn't be surprised.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GibTreaty · Oct 27, 2012 at 02:26 PM

SmoothDamp looks like it uses Time.deltaTime internally or some other method of keeping the smoothing consistent over each frame. Try replacing "Time.time - lastTime" with something constant and it should work. Like putting a 1 should smooth it for one second. I could be wrong but I have used SmoothDamp before and noticed that putting Time.deltaTime in that parameter slot is pointless.

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

12 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

Related Questions

SmoothDamp smoothTime ignored! 1 Answer

SmoothDamp keeps changing back 0 Answers

When to use Time.deltaTime? 3 Answers

Transform localPosition on time 2 Answers

Working with probability over time 3 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