trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 06:51 PM |
is it possible to get a random vector3 between 2 positions? my code:
function findRandomChild(model, max, min) local Model = model:children()[math.random(1,#model:children())] Model:MoveTo(math.random(min, max)) end
--i am trying to get it so that it will move the model to a random position between min and max which is a vector3 |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
| |
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 07:38 PM |
| Anyone!? lol i been waiting for like 30 mins |
|
|
| Report Abuse |
|
|
Exzeption
|
  |
| Joined: 01 Nov 2011 |
| Total Posts: 1312 |
|
|
| 14 Nov 2016 07:38 PM |
there's probably a more efficient way to do this but:
local v1 = --something local v2 = --something else
local v = Vector3.new( math.random(math.abs(v2.X-v1.X)), math.random(math.abs(v2.Y-v1.Y)), math.random(math.abs(v2.Z-v1.Z)) )
~The Low Brass Master |
|
|
| Report Abuse |
|
|
Exzeption
|
  |
| Joined: 01 Nov 2011 |
| Total Posts: 1312 |
|
|
| 14 Nov 2016 07:41 PM |
if you're doing it on a large loop do
local mathr = math.random local mathabs = math.abs local vector3 = Vector3.new
local v1 = --something local v2 = --something else
local v = vector3( mathr(mathabs(v2.X-v1.X)), mathr(mathabs(v2.Y-v1.Y)), mathr(mathabs(v2.Z-v1.Z)) )
~The Low Brass Master |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 07:46 PM |
| kk im not so sure which one to use, so i will try both |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 07:48 PM |
| Wait, so is v1 and v2 min and max? and which is min and which is max |
|
|
| Report Abuse |
|
|
Exzeption
|
  |
| Joined: 01 Nov 2011 |
| Total Posts: 1312 |
|
|
| 14 Nov 2016 07:49 PM |
v2 would be max, v1 min
Min and Max are Vector3s right?
~The Low Brass Master |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
| |
|
Exzeption
|
  |
| Joined: 01 Nov 2011 |
| Total Posts: 1312 |
|
|
| 14 Nov 2016 07:53 PM |
Wait, I made a mistake... This should do it
local v1 = --Min local v2 = --Max
local v = Vector3.new( v1.X + math.random(math.abs(v2.X-v1.X)), v1.Y + math.random(math.abs(v2.Y-v1.Y)), v1.Z + math.random(math.abs(v2.Z-v1.Z)) )
~The Low Brass Master |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 07:54 PM |
bad argument #1 to 'random' (interval is empty)
Does that error mean anything to you? |
|
|
| Report Abuse |
|
|
Exzeption
|
  |
| Joined: 01 Nov 2011 |
| Total Posts: 1312 |
|
|
| 14 Nov 2016 07:56 PM |
local v1 = --Min local v2 = --Max
local v = Vector3.new( v1.X + math.random(math.abs(0, v2.X-v1.X)), v1.Y + math.random(math.abs(0, v2.Y-v1.Y)), v1.Z + math.random(math.abs(0, v2.Z-v1.Z)) )
~The Low Brass Master |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 07:56 PM |
| oh did not refresh page to see that u posted somthing i will try that |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 07:58 PM |
Same error
bad argument #1 to 'random' (interval is empty) |
|
|
| Report Abuse |
|
|
Exzeption
|
  |
| Joined: 01 Nov 2011 |
| Total Posts: 1312 |
|
|
| 14 Nov 2016 07:59 PM |
wow i need to sleep
local v1 = --Min local v2 = --Max
local v = Vector3.new( v1.X + math.random(0, math.abs(v2.X-v1.X)), v1.Y + math.random(0, math.abs(v2.Y-v1.Y)), v1.Z + math.random(0, math.abs(v2.Z-v1.Z)) )
~The Low Brass Master |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 08:03 PM |
| By the way... i just thought about something. how will i know which number is the max when some numbers are bigger than others(in the vector3) |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
| |
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 08:15 PM |
Uhh you there? cuz i got to go at :30
(less than 15 mins) |
|
|
| Report Abuse |
|
|
trytry1
|
  |
| Joined: 18 Dec 2010 |
| Total Posts: 129 |
|
|
| 14 Nov 2016 08:20 PM |
| I guess you fell asleep at the computer... |
|
|
| Report Abuse |
|
|