- Home /
mathf.pingpong
hi, iam using mathf.pingpong, but it usually start position from (0,0,0), even if me change the position in the scene or from the script ! this code in Awake() to change the position randomly but didn't wok and also start from (0,0,0) randomRange = Random.Range (1, 10); transform.position = new Vector3 ((randomRange - 10f) + 10, transform.position.y, 0.0f); what can me do to solve this ? and if me want to move this object between negative and positive position, like from (-5, 5) in x ,, how to make this ? thank alot :)
Answer by meat5000 · Feb 25, 2015 at 08:08 PM
You probably need it in Update rather than Awake or Start
It did work. It just gave you 1 instantaneous return value ins$$anonymous$$d of what you thought it was going to do.
For it to do what you want youve got to keep calling it.
Look at the docs. Its in Update and using time to vary the value.
Your answer
Follow this Question
Related Questions
Mathf.PingPong from a random position problems 0 Answers
Ping pong position using lerp 3 Answers
spawn muzzle flash with random rotation? 2 Answers
How can I calculate and place a GameObject at a random place just outside the camera frustrum? 0 Answers
Int Based PingPong or oscillation without using Mathf.Pingpong? 2 Answers