 How do I make multiple parts form into a circle around the player?

Hello! I was wondering how could I make multiple parts form into a circle around a player.
Im working on a pet system and i wanted to know how i could create this type of system

• This is what I have right now:

If anyone would help me that would be great!

2 Likes

This has been asked before and I’ve seen this post recently. Let me know if it helps.

2 Likes

Ive already seen that post, but I don’t understand how i can put that information into my system

What you’ll probably want to do is make the BodyPosition's Position value equal to the return of a function that you call every time a pet is added to the character. This function would loop through all the pets you set and store in a table and reposition the existing BodyPositions.

could you possibly explain a bit more for me?

I would recommend using an OOP style module script for your system. But however you create it you’ll probably want to create a way to set a table for the amount of pets you have in the character for the equation. Create a function to be able to be referenced by the system with a script inside it with something like this:

local function GetBodyPosition(Pets--Table you set and store)
--Do the circular equation for each pet
return EquationResult
end

Then connect a function to the system for every time you add or remove a pet and have it call the function to get a new position for the pet.

1 Like

You want to use some basic trigonometry here. Have it be where it selects a number from 0 to 1 then apply the coordinates to be the cosine and sine of whatever relative. I got a tutorial on this if u still confused

2 Likes

Then do I set the body position using that function? Or how?

Yes, you make the function return the solution inside the function. So, say that you want to set the body position after creating the new pet. You would run the function as the body position property when setting it so it will return the body position and set it. It should looks like this.

[#Pets + 1] = Pet--Set the new pet's index number within the table's dictionary so it can be easily indexed.

local function GetBodyPosition(Pet)
local Position
local IndexNumber = 0
for I, V in next do
IndexNumber += IndexNumber
if V == Pet then
Position = CircularEquation(IndexNumber)
break
end
end
--[[
Use the dictionary index integer in a function to get the position based on its index integer and the total amount of pets currently in the table.
]]--
return Position
end

Pet.Model.PrimaryPart.BodyPosition.Position = GetBodyPosition(Pets[Pet])
--This will run the function with a parameter of the Pet's index integer so that it can get the position based off the returned value(result of the equation using the Pet's index integer.)

When you add a new Pet to the Pets table you should do this to make sure it’s added to the dictionary with an index integer. When you want to remove a pet use its integer from a saved value, or something like that.

1 Like

What would be Circular Equation Part? Is it a function?

It would be the equation for that part’s position out of how many pets are currently in the table. You would make a function that returns the value of the position based off the formula using the index integer in that post I sent in my first reply.

Are you talking about the OOP ?

This would probably be the function for Pet.new in an OOP module script, but I’m talking about getting the position to set with a function inside of your pet system.

OOP just stands for Object Oriented Programming. That would be what I recommend you use for the structure of your system, but you don’t need to if you already have that setup.

1 Like

So this then? Or what do you mean

Yes, you would have to create a function like that with the number of the children and the current child’s index integer to get the product of an equation from the post and then return it through that function.

1 Like

How would i do the circle equation in that function?

Read the post in my first reply. They explain it in lots of detail and exactly how to get what you’re looking for. The only thing that they didn’t explain is how to implement it into your system which is what I explained in my replies. Did you read the post I’m talking about?

Its the OOP right? I didn’t read it, but ill go ahead and read it right now that i have time

What I’m talking about is that when you create an OOP system in a module script you would create a function using their code for your situation and make it easier to access by doing so.