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 Kennyist · Oct 10, 2013 at 10:01 AM · c#rotationtransformmath

How to Reverse an equation.. (c#)

I have this equation:

 float temproll = roll / 1.66666f;       // Devide roll by 30
 temproll = (temproll - 30.0f);          // - 30
 helirollSpeed = Mathf.Abs((temproll));  // Turn negative into positive

Which provides me a speed on this sale:

alt text

But now i need to reverse this for a rotation to speed conversion like this:

alt text

How would I go about this. Or how else could I turn rotation amount into a speed by this scale?

untitled.png (59.2 kB)
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 Doireth · Oct 10, 2013 at 10:11 AM 0
Share

Sorry, I'm having trouble understanding what exactly you are trying to do. However, to invert a value simply subtract it from the maximum possible value it could have.

avatar image Kennyist · Oct 10, 2013 at 10:14 AM 0
Share

I'm trying to convert a rotation from 0 to 90, into a speed value. Where 0deg = 0 speed , 45deg = 30.0 speed and 90deg = 0 speed. Like the second scale image.

2 Replies

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

Answer by ArkaneX · Oct 10, 2013 at 10:23 AM

It's very similar to the response which @Hoeloe wrote as answer to one of your previous questions. Solution:

 speed = 30 - Mathf.Abs((angle - 45) / 1.5f);

Description from Hoeloe's answer still apply, with the difference that you have to subtract the result from 30 to inverse speed.

Comment
Add comment · Show 4 · 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 Nexum1 · Oct 10, 2013 at 10:27 AM 0
Share

That also works! :-)

avatar image Hoeloe · Oct 10, 2013 at 12:49 PM 0
Share

You might want to consider studying up on simple mathematics - these are all just linear mathematical relations, and those are vitally important for any game's development.

avatar image Nexum1 · Oct 10, 2013 at 02:03 PM 0
Share

Sorry @Hoeloe, I have no idea who you are referring your comment to.. The original question asker, $$anonymous$$e or @ArkaneX? If you were referring to the original asker, you might consider commenting on the question itself.

avatar image Hoeloe · Oct 10, 2013 at 03:01 PM 0
Share

I was referring to the OP, sorry. I meant it as an extension of this answer - I realise now that I didn't make this clear.

avatar image
1

Answer by Nexum1 · Oct 10, 2013 at 10:24 AM

What you could do is create a public AnimationCurve In unity, set the animation so that at 0.5 (50%) the value is 30 and at 0 (0%) and 1 (100%) the value is 0.

Then get a percentage from the value you are trying to convert..

Value/90=Percentage

Then, get the value from the animation curve using that percentage.

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

19 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

Related Questions

Flip over an object (smooth transition) 3 Answers

accessing an array of rigidbodies at once? c# 2 Answers

RotateAround Limitations 2 Answers

I need an object to rotate using a moving object as a pivot. 0 Answers

Unit rotation fails consistently on all slerp rotations after the first? 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