unity mathf.pingpong code example
Example 1: unity pingpong
void Update()
{
// Set the x position to loop between 0 and 3
transform.position = new Vector3(Mathf.PingPong(Time.time, 3), transform.position.y, transform.position.z);
}
Example 2: mathf.pingpong unity rotatiion
transform.rotation = Quaternion.Euler(0f, Mathf.PingPong(Time.time * rotateSpeed, 90f), 0f);