Skip to content

Instantly share code, notes, and snippets.

@Lkledu
Created February 13, 2020 23:49
Show Gist options
  • Save Lkledu/9f2bd4cdc092a2f3c20c69b218907bf0 to your computer and use it in GitHub Desktop.
Save Lkledu/9f2bd4cdc092a2f3c20c69b218907bf0 to your computer and use it in GitHub Desktop.
ping pong movement
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pingPongTitle : MonoBehaviour
{
public float m_Range = 0.1f;
public float m_SmoothTime = 10.0f;
public Vector3 m_Axis = Vector3.up;
private Vector3 m_Origin;
void Start()
{
m_Origin = transform.position;
}
void Update()
{
transform.position = m_Origin + 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