Created
September 6, 2019 03:49
-
-
Save kleberandrade/af90e782efe05815f2dce64e972e57f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Oscillator : MonoBehaviour | |
{ | |
public Vector3 m_Axis = Vector3.up; | |
public float m_Range = 0.3f; | |
public float m_SmoothTime = 2.0f; | |
private Vector3 m_OriginPosition; | |
private void Start() | |
{ | |
m_OriginPosition = transform.position; | |
} | |
private void Update() | |
{ | |
float movement = m_Range * Mathf.Sin(Time.time * m_SmoothTime); | |
transform.position = m_OriginPosition + m_Axis * movement; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment