Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Akkronym · Oct 08, 2015 at 01:38 AM · randomlerpboundsweightaverage

Calculating a value based on a weighted element within bounds?

I'm trying to write a script that will allow a game object to move in a general direction within specified bounds rather than in a specific direction. Based on what I've seen with the function LerpAngle, the angle portion won't be particularly difficult I think. It works by using a minAngle and maxAngle and interpolating between them based on a value "t" that must be between 0 and 1 inclusively. If t is 0.5, it will return the exact midpoint of the two angles; if it is 0, LerpAngle returns minAngle, and if it is 1, LerpAngle returns maxAngle.

I'll have the ideal vector (calculated elsewhere and already working) which will be identical to the midpoint, and I'll be able to treat minAngle and maxAngle as a +/- threshold from this ideal midpoint.

What I'm trying to do is programatically calculate a "t" value based on an "amplitude" variable.

When the amplitude is 0, t is calculated completely randomly. IE values should be effectively indistinguishable from the performance of t = Random.Range(0f,1f);

When the amplitude is 1, t = 0.5 no matter what.

When it is any value in between 0 and 1, I'd like it to sort of be a gradient that plots like a progressively more narrow bell curve from 0 to 1.

Rough sketch of expected performance - alt text

I'm not really sure how to implement this, but it seems like something that might already have a library function somewhere - if not necessarily unity. Can anyone either point me in a helpful direction for writing it myself, or towards an existing function that does something similar?

unnamed.png (44.4 kB)
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 Akkronym · Oct 08, 2015 at 03:58 AM

With the help of a friend I was able to figure out that the concept I'm referring to here is Normal Distribution and Random Gaussian Variables.

I don't have a working implementation yet, but based on what I've found so far a "Box-Muller Transformation" keeps coming up and seems like an effective direction to go in.

Hopefully this will help point anyone else with this issue in the right direction as well.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Calculate weighted mean based on direction 0 Answers

How to 'Lerp' random local vectors? (Solved!) 3 Answers

Vector3 Lerp mis-match 0 Answers

Linear interpolating (Lerping) a Gameobject between random positions of Other GameObjects 1 Answer

How do I smoothly shift between Layer Weights 2 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