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 NecrosDk · Oct 24, 2012 at 07:50 PM · speedmathfsmoothdamp

Mathf.Smoothdamp, need help troubleshooting!

Hi,

I have an object rolling at a speed, with a deceleration. When i pick up muffins in the level, the object gains a speed, and I want that speed to be gained over smoothtime with smoothdamp. Here is my code:

if (other.gameObject.tag == ("Muffin") && Time.time - muffinpickuptime >= muffinminicooldown) {

             muffinpickuptime = Time.time;
             Destroy (other.gameObject);
             gainingspeed = true;
             moveDirection.x = Mathf.SmoothDamp(moveDirection.x, moveDirection.x + MuffinSpeed,ref moveDirection.x,muffinSmoothTime,maxspeedx);

furthermore I disable all deceleration with a gaininspeed check, so there is no deceleration as long as smoothdamp is running (setting it to false after muffinsmoothtime seconds) So i am 100% sure that there are no other lines of code changing the value of moveDirection.x.

What happens when I pick up a muffin now, is that i only get 0.2 more speed on my object, while my muffinspeed is set to 5. I am 100% sure they collide. simply checking for the gainspeed bool in update and putting the smoothdamp there did not help, and gave weird results.

I tried with having 0 as speed also, with no results.

Anything I have overlooked? Can anyone see my mistake?

PS: using a character controller and moving it every frame with value moveDirection.

Thanks for your time :)

Comment
Add comment · Show 1
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 NecrosDk · Oct 24, 2012 at 08:17 PM 0
Share

Alright, in the 5 hours I was waiting for mod approval, I found out that if I dont put the smoothdamp in update, it will only run for that one frame that the muffin is hit.

So I went back to checking for the bool, and threw it in the update. It is not exactly precise. I want a gain of 5 in speed, and it adds between 4 and 6.5. The higher speed, the more it adds. Also it doesn't care about my muffinspeeed actually. It just keeps on adding its own speed for as long as it's active, which means the longer smoothtime, the more speed will be added in the end. I found my sweet spot though.

I also realised that if i say movedirection.x+muffinspeed as target, the target will be ever changing, therefore I stored the speed as it hit the muffin, and used that speed + muffinspeed. I still have the same result though. It is not game breaking, cos I achieved the effect that I wanted. The little deviation in the speedgain is just a tad annoying and I would of course love to have it fixed.

0 Replies

· Add your reply
  • Sort: 

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Ramping animation speed 2 Answers

How can I smooth out the crouch movement? 1 Answer

Whole number Mathf.SmoothDamp ? 1 Answer

How does Mathf.SmoothDamp's max speed work? 1 Answer

SmoothDamp: reference velocity always 0 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