1. Submit bugs to enter our 5.4 Beta Sweepstakes. Read more about it here.
  2. Unity 5.4 public beta is now available for all users. Grab the build and visit the 5.4 beta forum.
  3. Missing a module? More about the new installer in 5.3 here.
  4. 4.7.1 released for Xcode 7.3 support. Thread here.

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:
    851
    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!