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
2
Question by Karsnen_2 · Oct 04, 2012 at 06:01 PM · c#rotationrigidbodyios

How to create a damped harmonic oscillation?

Hello,

I am building an iPad app and a cube of scale 4 1 4 and the game is a top down view game. As the user, tilts the iPad I am trying to yield a Damped Harmonic Oscillation on the cube. Hence the oscillation would only be on 2 directions which is X & Z. In layman terms, there would be a wobble on the cube.

GameView: alt text

The game is face negative Y axis or mathematically the camera is tilted 90 degrees across x axis.

Dissecting :

Considering just one direction, the graph would be like this -

alt text

So if a user gives a input, I would calculate the target value and then apply it to a function which would calculate the required value and then oscillate the cube. I visualize to perform the oscillation by AddForceAtPosition on Vector3.down.

Can you devs help me with this?

Thank you & Please...

regards,

Karsnen

Additional Links:

http://phrogz.net/damped-spring-oscillations-in-javascript

http://farside.ph.utexas.edu/teaching/315/Waves/node9.html

http://wiki.unity3d.com/index.php/File:Mathfx-Bounce.png

screen shot 2012-10-05 at 10.56.24 am.png (320.3 kB)
Comment
Add comment · Show 4
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 Fattie · Oct 04, 2012 at 06:04 PM 0
Share

why don't you just take the board and use a spring component ?

(look in the menus for "spring", also read the doco on it. you can get to the doco by clicking the doco (book) button on the component)

avatar image Karsnen_2 · Oct 04, 2012 at 06:18 PM 0
Share

Hmmm.. fattie. I think I did try that too. But I will try it in a different manner now.

avatar image Karsnen_2 · Oct 05, 2012 at 02:59 PM 0
Share

Fattie, I was not able to get the required through springs. Hence I changed the approach and the question.

avatar image maxjt · Oct 09, 2012 at 08:20 PM 0
Share

Why not directly use transform.Rotate() or assign transform.eulerAngles? Use somethig like (sin t) / t function.

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by MountDoomTeam · Oct 09, 2012 at 08:55 PM

Hiya, so the graph you want is a SIN or COS wave, so you take time.Time, use it as a ramp, multiply time.Time by a multiplier number to get the speed you want on the sine oscillations, and then multpiply the sine itself by an envelope, in your case it is abit like an exponentially dampening/waning envelope... you can make the waning envelope with some cheap exponential functions from the net, for example one way of making an curved decrease like that, is by taking a ramp (using a version of time.Time that resets to zero every time you want the envelope to retrigger) and doing a sqrt or a cube root or a square or a cube, like this :

link text

In other words, take time.time, sine or cos it, multiply the result by an envelope equation also based on a function of time.time.

if you want different speeds and amplitudes and periods for x and y axes of the crate, do 2 versions of time dot time, with different amounts added and multiplied to them, and apply each to Sin and then to x and y.

if you decide that sin and cos arent exactly right, you can pass cos through asin or sin through acos to have a triangle oscillation, or you can do a modulo of time.time and then make an absolute of that modulo which will also give you a triangle wave and is less processor hungry than sin. you can also multiply that triangle wave by itself to make it rounder. :)

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

11 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Help regarding World-Local Transfrom Rotation? 1 Answer

[Solved] Is it okay if we change transform.position on a kinematic rigid body which also does not use Gravity? 2 Answers

Performance Question on Kinematic Rigidbodies 1 Answer

How to tilt the gameobject based of Input.Acceleration? 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