hi.
how do i make some things equally spread out?
local radius = 15 + (HugeCount/10)
local Angle = math.pi/HugeCount
local PetAngle = Angle*HugeI
this is what i have
And i need it to be equal across the whole half circle
hi.
how do i make some things equally spread out?
local radius = 15 + (HugeCount/10)
local Angle = math.pi/HugeCount
local PetAngle = Angle*HugeI
this is what i have
And i need it to be equal across the whole half circle
Half a circle is 180 and you have x amount of pets. You don’t need Pi to know that the angle between each pet should be 180 / x and as such the formula for the angle would just be 180 / x * n where n is the pet number.
that wouldn’t make it equal that’s practically the same what i’m doing but with ur method you would just have to do math.rad in the cframe
I don’t understand what you’re asking for then?
wait but what’s x supposed to be
X would be the number of pets in total
It’ll be an issue of how you’re actually positioning them then rather than with the formula itself.
local CF = player.Character.PrimaryPart.CFrame * CFrame.Angles(0,PetAngle,0) * CFrame.new(radius,0,0)
Hmm… Do you see anything that could break it?
edit forgot math.rad
Could you show how you’re looping and using pet angle? Seems that will be your problem.
I’m looping with renderstepped and here:
local radius = 15 + (HugeCount/10)
local PetAngle = (180/HugeCount + 1) * (HugeI-1)
local CF = player.Character.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(PetAngle),0) * CFrame.new(radius,0,0)
You have an order of operations typo, it would be
180/(HugeCount - 1) instead of (180/HugeCount + 1)
Im not home to give a better answer but that’s probably your main problem.
Seems to be exactly the same
local totalCount = 9
local radius = CFrame.new(15 + totalCount / 10, 0, 0)
local _, y, _ = Origin:ToOrientation()
local rotation = CFrame.fromEulerAnglesXYZ(0, y, 0)
for i = 0, totalCount - 1 do
local angle = math.pi / (totalCount - 1) * i
local petCFrame = Origin * CFrame.fromEulerAnglesXYZ(0, angle, 0) * radius
local newPet = Pet:Clone()
newPet.Parent = workspace
newPet:SetPrimaryPartCFrame(CFrame.new(petCFrame.p) * rotation)
end
This should point you in the right direction, hope this helps.
It was probably an issue with how you were positioning them. You can also reduce redundant CFrame constructors inside the loop to squeeze out some more performance.
This is just the function, you will do the setting of positions of the pets.
local pivot = CFrame.identity -- Center; Probably the HumanoidRootPart.CFrame
local pets = 10 -- Number of pets
local radius = 15 + pets/10 -- Radius
for i = 0, pets-1 do
local sin, cos = math.sin(i*math.pi/(pets-1))*radius, math.cos(i*math.pi/(pets-1))*radius
local CFramePos = pivot*CFrame.new(cos,0,sin) -- CFrame of a pet
-- Your code
end
Modify pivot
and pets
. Use CFramePos
to position a pet, then you do the rest.
.
Half a circle is 180 degrees, but in programming and some calculators, pi is 180 degrees too, so math.pi/x == math.rad(180/x)
. You just added an extra step by calling math.rad()
.
.
What’s the purpose of making radius
a CFrame if you will index it’s position anyways?