Battle Royale Storm Assistance

Currently I;m trying to make a little battle royale storm, but I have a problem I cannot solve.

My stiorm needs to go INSIDE itself, currently its going partially inside of the original storm circle, and partially outside of it. Heres my code and a video.

(On a hotspot currently, lights are out, cannot provide a video. :frowning:)

Code:

--[[
   Syntax:
   
   stormModule:tweenStorm(ins stormObject, int mainSize,  int timeToTake, vector3 position)
   makeRandomPosition(ins object)
]]--

local stormModule = require(script.Parent.stormModule)

local randomPosition
local stormObject = workspace.stormMain

local function makeRandomPosition(obj)
   local a
   local b = 0
   local c
   local xVal = stormObject.Size.X
   
   a = math.random(1, xVal/4)
   c = math.random(1, xVal/4)
   return Vector3.new(a, b, c)
end

local nextPos = makeRandomPosition(stormObject)
function makePart()
   local part = Instance.new("Part", workspace)
   part.Position = nextPos
   part.Transparency = 0.9
   part.Size = Vector3.new(1, stormObject.Size.X/4, stormObject.Size.X/4)
   part.Shape = "Cylinder"
   part.Orientation = Vector3.new(0, 90, 90)
   part.Anchored = true
   part.CanCollide = true
end
while wait() do
   position = nextPos
   print(position)
   local mainSize = stormObject.Size.X/2
   stormModule:tweenStorm(stormObject, mainSize, 10, position)
   nextPos = makeRandomPosition()
   makePart()
   wait(5)
end

(The problem is with the makeRandomPosition math I believe)

I have an image to try to explain, though.

The big circles are previous locations, you can see that they do not always go in the center of the previous circle. One thing Id appriciate help with would be the fact that the circle ALWAYS ends in the middle of the baseplate. Thank you! :))

3 Likes

If you want it to be in the center of the baseplate, maybe remove the random positions function? It serves no purpose unless you want the circle to actually move to another location. If you want each circle to be inside of each other all you will need to do is tween the circles.

Unless of course you want it to be a random position inside the previous circle, which would require you to add an argument to the function in which the bounds for the math.random statement is the size of the previous circle.

1 Like

The first thing you mentioned is exactly what I do not want, the second though, I thought I had done, but obviously it doesnt work and idk how to make it work, either.

Have the random position value limited to a position to where it is inside the previous circle, also note the radius, so that part of the new circle is not outside the previous circle.

The position of your next circle must be within your previous circle yes?
So now know our next circle’s position must be at least something like;
MaxDistance = Vector(3,0,3)
NewCirclePos = CirclePos ± MaxDistance
That’s the max min our new circles position might lie within.
However, that would mean, in some examples, that our new circles radius would be outside our current radius!
So, let’s find out what our new radius is and subtract it from our MaxDistance.
MaxDistance = Vector(3,0,3) -Vector3(newradius, 0, newradius)

Our new circle is always within the old!

In order to do this, you must ensure your first circle encompasses this area to begin with. Instead of giving you the exact code, I’ll provide you with the logic required to code this:

The first circle must have a radius scaled to match the distance away from the center such that it creates an envelope around the position you want to end at. Decide how big the last circle should be, and add that radius to your initial calculation.

The consecutive circles must also encompass the end location in mind, while being inside of the previous circles, so you must keep the end goal in view. In order to make sure the next circle is inside of the previous one, you will need some math. I’d follow the example by @edenojack while also keeping in mind you need to include the ending point.

Hopefully this was helpful to you and gives you a place to start! Good luck on your Royale game mode!

An alternative, if you want a specific point on the map to be your ending location, just work backwards! The math within my example should work with some swapping around too, so not much more there!

1 Like

Oh my, sorry, my problem is that it aleays ends there, I want the ending position to be random. :slight_smile:

sorry for not being too clear!

Ill try this whenever I get on my PC, thanks for contribution! :slight_smile: