Skip to content

Instantly share code, notes, and snippets.

@kleberandrade
Created February 13, 2020 19:32
Show Gist options
  • Save kleberandrade/35b7cc2296b8a149a31e4b24117cdd59 to your computer and use it in GitHub Desktop.
Save kleberandrade/35b7cc2296b8a149a31e4b24117cdd59 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class PingPongUI : MonoBehaviour
{
public float m_Range = 0.05f;
public float m_SmoothTime = 10.0f;
public Vector3 m_Axis = Vector3.up;
private Vector3 m_StartPosition;
private void Start()
{
m_StartPosition = transform.position;
}
private void Update()
{
transform.position = m_StartPosition + m_Axis * Mathf.Sin(Time.time * m_SmoothTime) * m_Range;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment