1. Before updating to Windows 10 you may need to return your Pro license. More information here

Shake an object from script

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

  1. FootprintGames

    FootprintGames

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

    flaminghairball

    Joined:
    Jun 12, 2008
    Messages:
    831
    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!