Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SineBob : MonoBehaviour
- {
- [SerializeField]
- private float strength = 1.5f;
- [SerializeField]
- private float speed = 2.0f;
- private Vector3 startingPosition;
- void Start()
- {
- startingPosition = transform.position;
- }
- void Update()
- {
- float yOffset = Mathf.Sin(Time.time * speed) * strength;
- transform.position = startingPosition + new Vector3(0.0f, yOffset, 0.0f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement