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 McMutton · Oct 07, 2011 at 07:53 PM · mathnumberinverse

Getting an inversely proportionate value

Ladies, gentlemen.

I'm currently attempting to set up a system for equipped weapon stats, and I've run into an issue I'm not sure how to solve:

I've got a Float that represents the attack speed of the equipped weapon, the default of which is 1. This is used as the attack animation's speed:

 animation["Attack1"].speed = attackSpeed;

Further on in the code is a bit that uses WaitForSeconds to make it so you can't attack again until X seconds have passed, the value of which should get lower the higher the weapon's attack speed is, or vice-versa. The default of this one is .5.

So, for example, if the attack speed were 2, I'd say that X should be around .25. .5, and it'd be 1. How would one accomplish this?

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 Owen-Reynolds · Oct 07, 2011 at 08:10 PM 1
Share

In your Q title, you ask for the inverse. Why doesn't the actual inverse -- 1/attackSpeed -- work, or, in your case: Waitfor( 0.5f / attackSpeed)?

I'd probably change attackSpeed to the actual delay in seconds, then use 2/attackSpeed for the animation speed.

avatar image McMutton · Oct 07, 2011 at 08:23 PM 0
Share

Ah, with a tiny adjustment, that first one worked. Thanks, ye! I was actually unaware of that inverse equation.

1 Reply

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

Answer by McMutton · Oct 07, 2011 at 08:24 PM

Based on Owen's comment, I figured it to be 1/(attackSpeed * 2)

Comment
Add comment · Show 2 · 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 Owen-Reynolds · Oct 08, 2011 at 05:16 AM 0
Share

Divided by 2 and times 0.5 are the same. I prefer 0.5/attackSpeed since it has your 0.5 base delay in it, adjusted by speed. Say you want 0.75 base delay, can change to 0.75/attackSpeed.

With the attackSpeed/2 way, changing to a base delay of 0.75 comes out to the ugly attackSpeed/1.33333 (try it -- for ASsp=1 you get 1/1.333 = 0.75.)

avatar image McMutton · Oct 08, 2011 at 07:32 AM 0
Share

It's not so much that the 'base' value is .5, it's that .5 is the value I end up with if the weapon's attack speed is 1.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Maths issue + Null reference error? -1 Answers

How to create a standard deviation number generator? 2 Answers

What is the rotation equivalent of InverseTransformPoint? 3 Answers

How to get inverse of a lerp function 1 Answer

how to keep fraction number ??? 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