Originally, I was using the ScriptReference for Mathf.PingPong, but unfortunately, it would automatically move the object so that it’s Z value would be 0. How can I prevent this so that the object will PingPong from its current position? Here’s the ScriptReference for Mathf.PingPong:
transform.position = new Vector3(Mathf.PingPong(Time.time, 3), transform.position.y, transform.position.z);