Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Oscillator : MonoBehaviour
  4. {
  5. public Vector3 m_Axis = Vector3.up;
  6. public float m_Range = 0.3f;
  7. public float m_SmoothTime = 2.0f;
  8. private Vector3 m_OriginPosition;
  9.  
  10. private void Start()
  11. {
  12. m_OriginPosition = transform.position;
  13. }
  14.  
  15. private void Update()
  16. {
  17. float movement = m_Range * Mathf.Sin(Time.time * m_SmoothTime);
  18. transform.position = m_OriginPosition + m_Axis * movement;
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement