Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 $$anonymous$$ · Aug 20, 2020 at 03:19 PM · variablefloatcurveanimationcurvecar game

Animation Curve to Float variable? help!

Hello, I'm trying to make a float variable follow a specific pattern, and the animation curve serves me a lot, but I can't get it to follow this pattern (I'm simulating a gearshift effect with different tones).

Thank you!

 //EngineRPM is a float
 //ShiftingCurve is a animation curve
 
 EngineRPM = ShiftingCurve;

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 The_Three_Vs · Aug 20, 2020 at 07:10 PM

Is the animation already configured in the pattern you want? To get the value out of an AnimationCurve you need to use ShiftingCurve.Evaluate(t) , where t is the x-value you want to get the curve value of.

Comment
Add comment · Show 7 · 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 $$anonymous$$ · Aug 20, 2020 at 08:52 PM 0
Share

Yes, it's a V-shaped curve (go down and up at the end)

And when using ".Evaluate (Time.time)", it does not work, that is, the float value does not go down and go up as in the curve.

 EngineRP$$anonymous$$ = ShiftingCurve.Evaluate(Time.time);
 
avatar image The_Three_Vs $$anonymous$$ · Aug 20, 2020 at 09:08 PM 0
Share

In your curve, is there a gray line on either side? Since Time.time is an always-increasing value, in order for the curve to return changing values the right side of the curve must be set to "Loop".

avatar image $$anonymous$$ · Aug 20, 2020 at 09:25 PM 0
Share

Exactly !, I put it in loop mode.

But, when the car makes the change (which is when the value must follow the pattern of the curve, simulating a deceleration for clutch or gear change), that same value stays at 1.

The line of code is the same:

  EngineRP$$anonymous$$ = ShiftingCurve.Evaluate(Time.time);
 

 



avatar image The_Three_Vs $$anonymous$$ · Aug 20, 2020 at 09:39 PM 0
Share

When you say "that same value stays at 1.", what value are you referring to?

Let me see if I understand what you want to happen - You have a float variable EngineRP$$anonymous$$ that represents the speed of your car. At any point, when a clutch or gear change occurs, you want EngineRP$$anonymous$$ to decrease and then increase, causing the car to slow down and then speed up again. Is this correct?

avatar image $$anonymous$$ The_Three_Vs · Aug 20, 2020 at 09:47 PM 0
Share

Yes! exactly, is correct (In this case it is because the shape of the curve is in V)

Now, there is a float value, which is Engine RP$$anonymous$$, which, I assigned that when the car changes gears, that value is equal to the curve in a period of time (the change time, but that does not influence).

That is, if the curve is V-shaped, for example, the EngineRP$$anonymous$$ value goes down and up once simulating the change (this depending on the shape of the curve).

But, with that little piece of code, what happens is that when making the change, the value EngineRP$$anonymous$$ stays at the value of 1 and passed the time, returns.

 if(Shifting == true)
 {
 EngineRP$$anonymous$$ = ShiftingCurve.Evaluate(Time.time);
 }
Show more comments

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

137 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

Related Questions

Get value from a cruve like in AnimationCurve? 1 Answer

summing up items price in runtime 1 Answer

key count: 1 on curve 'curvename' error 1 Answer

Engine animation curve 1 Answer

Check increasing float variable 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