Created
February 13, 2020 23:49
-
-
Save Lkledu/9f2bd4cdc092a2f3c20c69b218907bf0 to your computer and use it in GitHub Desktop.
ping pong movement
This file contains 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 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