- Home /
Question by
Crispinator · Jan 13, 2015 at 12:59 AM ·
randomdistancerandom.rangeteleport
Make an Object teleport a Random distance away.
I need an object to teleport a random x distance between two numbers, and a random y distance between two numbers. Any suggestions?
Comment
Answer by InvincibleCat · Jan 13, 2015 at 01:05 AM
float xDistance = Random.Range(xMin, xMax);
float yDistance = Random.Range(yMin, yMax);
Vector3 teleport = new Vector3(xDistance, yDistance, 0.0f);
transform.Translate(teleport);
Have fun!
Cheers!
Your answer
Follow this Question
Related Questions
Teleport to a random height 1 Answer
Transform to a random height 0 Answers
Random.Range(..) not working 1 Answer
How do you get different random numbers for each object array? 1 Answer
Random.Range not working. 1 Answer