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

How could I get a CFrame within the radius of another CFrame?

Asked by 6 years ago

So I'm randomly spawning items around a Part by using it's CFrame and so on.

But how would I get a random point within a radius around the Part.CFrame? Preferably I would like this second point as a CFrame.

0
Haha this would be very nice to know! Stephenthefox 94 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

I'm not sure if this is the answer you are looking for but ill try. So I personally would create a variable that stands for the degrees and a variable that stands for the distance. Let's let "dis" be distance and "deg" be degrees. You set dis to a random number that is less than the radius (math.random), and the deg to a random number from 0 to 360. (This is inside of the clone) Then set the CFrame of the clone to the CFrame of the Part, with the CFrame.Angles(0,math.rad(deg),0) * Cframe.new(dis,0,0). Looking at this it should work, but I am not sure. Then after that, if you want to now get the Cframe, just look at the position of the clone after the CFrame transformation. If you are still confused just ask.

Ad

Answer this question