- Home /
Random Range Position
Hello... our screen size is Android wide 3:6. We have this object that when clicked it must be changing position. This object is a plane.
here is our code for changing position
var position =Vector2(Random.Range(0,1),Random.Range(1,0));
we are not sure if we must use Vector2 and what random.range we should declare help please. thank you
the plane should change its position randomly when clicked. it should continue that way while the timer is running.
Answer by mirkobon · Sep 09, 2013 at 05:20 PM
var randomy : int;
var randomx : int;
function Update ()
{
// do here on mouse click
randomy = Random.range(-1.5,1.5)
randomx = Random.range(-3,3)
transform.position.y = randomy
transform.position.x = randomx
}
tell me if this worked
Answer by Seizure · Sep 09, 2013 at 04:47 PM
Watch using Random.range with int's, the max is EXCLUSIVE see reference Random.Range
So you are going from a range of 0 to 0 on the x and y is messed up anyways with a range min of 1 and max of 0 thats at least backwards.
sorry i were actualy wanting to make a float but i forgot to edit
Your answer
Follow this Question
Related Questions
translate 2 Answers
How to make cubes between 2 point and stick them together? 0 Answers
Two Firing points, Vectors 1 Answer
move to a position not being looked at 1 Answer
Find extreme points of rotated gameObjects? (screenshot example) 2 Answers