Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i get a random position on a non-rectangular object?

Asked by 5 years ago

I have a mob, a deer, in my game that currently has a rectangular base plate called the platform. In the following script i'm randomizing a point on that plate. My question is how can i do this on a non-rectangular plate like an oval, or any other weird shape i can create?

local Map = script.Parent.Parent.DeerPlatform 
local x = Map.Position.X
local xS = Map.Size.X / 2
local y = (Map.Position.Y + 1)
local z = Map.Position.Z
local zS = Map.Size.Z / 2
local start = script.Parent.Torsoa
local pos = Vector3.new(math.random(math.min(x - xS), math.max(xS + x)), y, math.random(math.min(z - zS), math.max(zS + z)))
0
Are you talking about Unions? DeceptiveCaster 3761 — 5y
0
You will need to do some math on the shape you have Fad99 286 — 5y
0
Yes like a union or a mesh part that has a non rectangular shape, also I know math needs to be done, I’m asking HOW to do that math, KamikazeJAM108867 38 — 5y

Answer this question