Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. public class SineBob : MonoBehaviour
  2. {
  3.     [SerializeField]
  4.     private float strength = 1.5f;
  5.  
  6.     [SerializeField]
  7.     private float speed = 2.0f;
  8.  
  9.     private Vector3 startingPosition;
  10.  
  11.     void Start()
  12.     {
  13.         startingPosition = transform.position;
  14.     }
  15.  
  16.     void Update()
  17.     {
  18.         float yOffset = Mathf.Sin(Time.time * speed) * strength;
  19.         transform.position = startingPosition + new Vector3(0.0f, yOffset, 0.0f);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement