generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Game Design
Home Search
 

Re: Random Vector3

Previous Thread :: Next Thread 
trytry1 is not online. 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 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
14 Nov 2016 07:31 PM
Bump.
Report Abuse
trytry1 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
14 Nov 2016 07:51 PM
Yes they are
Report Abuse
Exzeption is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
14 Nov 2016 08:04 PM
No error, but no clone
Report Abuse
trytry1 is not online. 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 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
14 Nov 2016 08:20 PM
I guess you fell asleep at the computer...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image