getting that random number is like this:
x=Random.Range(-4, 4);
http://unity3d.com/support/documentation/ScriptReference/Random.Range.html
but if you want sphere to move from 4 to -4 in ping pong motion use this:
transform.position = Vector3(Mathf.PingPong(Time.time, 8)-4, transform.position.y, transform.position.z);
Trending Articles
More Pages to Explore .....