|
| 11 Apr 2017 07:38 AM |
Is there a way to do this without being like:
local num = vector.X..vector.Y..vector.Z |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 11 Apr 2017 07:41 AM |
| You could use multiplication to "shift" different parts of the vector into different parts of the number to keep everything separate, but that's slow and not what numbers are for. What are you trying to do? |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 07:46 AM |
Trying to turn a vector or rotational CFrame from a constantly moving part into a number to be used as the seed for math.random, to get dynamic results and avoid repeating patterns from using static numbers.
os.time is not applicable in my case.
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 07:55 AM |
Like, an ordered pair(triplet)? Not sure if that's possible in roblox, you should probably just do something like
randomX = math.Random(vector.X)
etc.
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:00 AM |
Never set the seed more than once. If you think it's necessary, you don't understand how it works.
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:32 AM |
Well then I need help to know how it works, here's an image of my problem from a test server with 2 players: (Hopefully this won't be hashed. If it is, use this suffix to find an image on a certain popular image sharing site with black and green colouring and a giraffe mascot. Dkk1Vsu.png)
i. img ur. co m/D kk 1Vsu.png
I'm making a star-generator with FilteringEnabled on, so the stars you see are local content visible only to each player. As you can see, the layout of the stars are completely different.
Each star is generated using randomly-selected traits from 3 arrays (lists of brick colours, names, and sizes) and positioned by a vector made up of math.random's. The seed being used by each player to generate the stars is identical, but the end result is a different composition of stars.
Here's the code:
m############################ local NumberOfStars = math.random(1, MaxStars) for i=1, NumberOfStars do wait() local randomvector = Vector3.new( math.random(0, 100), --X math.random(-20, 20), --Y math.random(0, 100) --Z )
-etc, randomly selecting the traits
They actually contain the same number of stars (45), but everything else is different. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:33 AM |
| That hash is the random seed. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:34 AM |
What did you set the seed to? It was filtered.
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:35 AM |
Are you wanting them all to look the same to each player?
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:36 AM |
| Yes, the stars should be generated the same to each player. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:36 AM |
| The seed is just the numbers on the keyboard in chronological order starting from 1. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:38 AM |
You could generate them on the server. It has several advantages, one of them is you don't need to synchronize them manually. Another is that you can send one through a RemoteEvent or RemoteFunction and it won't error. Or do you have a reason not to?
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:39 AM |
I can do that, I didn't think of it. So, generate each star's information in a module script, return the info, build the physical star in a local script? |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:45 AM |
That works too, but I meant generate the stars in a regular Script. They will automatically stream to each client. Besides, ModuleScripts are LocalScripts when a LocalScript requires them, so they may still have the same problem.
Either way, the server (A regular script) needs to transmit the data to the LocalScript to load correctly. Another advantage of creating the actual stars with a Script is that they already exist for new players, no extra work for you.
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:49 AM |
Can't do it serverside, but nevermind, I just got it! -.o It's generating identically now.
I have no idea why this is the case but here is what was wrong:
It was structured like this: function GenerateStars() local function CreateStars() local seed = [seed here] --Build stars-- end end
Resulting in mismatching stars.
But I just put the seed outside the local function...
It was structured like this: function GenerateStars() local seed = [seed here] local function CreateStars() --Build stars--- end end
Works......
Stupid roblox. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:52 AM |
Uh, nope. Nevermind. I forgot I turned FE off, so it was all serverside. -Sigh-
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 08:54 AM |
I want you to know that I'm not doubting you or your reasons, but trying to get more info to find workarounds. What is the reason you can't add the stars from the server?
|
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 09:05 AM |
I could do it, but the star generator is my first step to generating a small true-scale galaxy, currently it can produce a field of about 100,000 to a few million stars around the position of the player and I hope to expand that to tens/hundreds of millions. Obviously if that were all being generated serverside the lag would be game-destroying, even if the players were thousands of blocks away from each other. So I've decided to procedurally generate them locally.
I want them to be identical so two players could visit the same star, but it's not totally necessary. Just a little annoying. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 09:12 AM |
Sorry, I phrased that badly. I mean that if the game had many players (e.g. 20) and each player has about 1000-2000 stars around them, then we're looking at ~40,000+ parts that the players have to render. Keeping it local reduces lag. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2017 09:15 AM |
I get you now.
You could read up on StreamingEnabled, which will only load parts of the map that players walk to (Make sure your LocalScripts don't break if it tries to access a part that's too far away to load) And (only if your computer can't handle it) they also start unloading parts of the map that are far away.
It speeds up game load times, and doesn't use as many resources if your computer can't handle it. Then just make the Script only generate areas that players travel to.
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|