1. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
  2. Enter the Google Play Indie Games Contest in Europe. Read more about it here.
  3. Unity 5.5 is now released.
  4. Become a closed-alpha partner on the new Facebook games platform. Read more about it here.
  5. Get early access to our Google Daydream Technical preview. Click here for more details!

Shake an object from script

Discussion in 'Scripting' started by FootprintGames, Jun 2, 2012.

  1. FootprintGames

    FootprintGames

    Joined:
    Mar 6, 2012
    Messages:
    303
    There's someone who can help me shaking an object using script?
     
  2. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Messages:
    861
    Code (csharp):
    1.  
    2. var speed = 1.0f; //how fast it shakes
    3. var amount = 1.0f; //how much it shakes
    4.  
    5. function Update()
    6. {
    7.   transform.position.x = Mathf.Sin(Time.time * speed);
    8. }
    9.  
     
  3. harko12

    harko12

    Joined:
    Jul 6, 2012
    Messages:
    3
    Worked great for me, Thanks!