For that I wanted to use a combo of lerping and cubic bezier curves. But the problem is, for the movement to look organic it cant repeat over and over again. I would like to make it so, that once my moving part passed 1 point, this point will move to a random position within a limited radius. But how would I achieve that and what would be the best way to loop with lerping?
You can try with a AlignPosition and each some time change it’s linear velocity or angular velocity, I think it will look good.
no. I dont want the movements to be straight, they need to be fluid
I heared about bezier tweening, maybe it would help?
Yea, I mean: Change them from Vectors with 1 of magntude each a few sec, for example:
local Part = script.Parent while true do Part.AssamblyLinearVelocity = Vector3.new(math.ramdom(1,100)/100,math.ramdom(1,100)/100,math.ramdom(1,100)/100) wait(0.5) end
It isn’t 1 of magnitude but It will have small changes.
isnt it gonna cause lag? And would the parts be moving how I imagined it too?
It won’t cause lag if the moveing is in the server since it have a lot of potence.
And I don’t know how do you imaginated, I just suppost that they will move kind of organic.
ok, my idea was that the parts will have an imperfect orbit
If you want a orbi, jus use the Tween Service with a Circular easing style to make it pass around some points. To be imperfect, don’t make the points on an exact cross. (5 sec draw:)
In this image, where the points are at the same distance frmo the center, it will be a “perfect” orbit.
In this one:
It will have some imperfections.
Red circles: Points to go
Green Cross: Center
I can achieve that with linear velocity, where its like an ellipse. By imperfections I mean it has a main ellipse or circle movement, but its all jiggly
Then I don’t know what else you can do if no one of what I said is usefull. Sorry.
I need the part to go on an imperfect path like in the drawing, each time there is a new imperfect path
To make it go in an imperfect path you can move the part in a circle around a center with some radius and then use math.noise() to add a value to that radius
Here’s code to do it, the NoiseSize variable will control how much the math.noise() will distort the path and NoiseTimeScale variable will control how fast it will wobble
local RunService = game:GetService("RunService") local Radius = 16 local NoiseSize = 6 local NoiseTimeScale = 1 local Speed = 1 local GameTime = 0 RunService.Heartbeat:Connect(function(dt) GameTime += dt local RadiusAdd = math.noise(GameTime * NoiseTimeScale) * NoiseSize local ActualRadius = Radius + RadiusAdd local t = GameTime * Speed local Position = Vector3.new(math.cos(t), 0, math.sin(t)) * ActualRadius end)
2 questions. 1st, is it a server script? second, will the orbit each time be new?
It can be both a server and a client script
If you put it in a client script it will be more smooth
Yes, it will
wonderfull, but I assume that not the whole script cuz its not specific to a part? Lets say I have 4 parts, called p1,p2,p3 and p4, can I create custom orbits for all of them all at once or does this script only work for 1 part?
Rn the script doesn’t support custom orbits, it only supports a circular orbit
by custom I meant that each of the 4 part have an orbit of their own, still circular though
Oh, the script is for a single part
I’ve made an updated script which has a function to make a part orbit another part and you can call it every RunService.Heartbeat for the parts you want to orbit and you can give each of them a different Radius, NoiseSize, NoiseTimeScale and Speed
local RunService = game:GetService("RunService") local GameTime = 0 local Radius = 16 local NoiseSize = 6 local NoiseTimeScale = 1 local Speed = 1 local function UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, MovingPart, Orbit) local RadiusAdd = math.noise(GameTime * NoiseTimeScale) * NoiseSize local ActualRadius = Radius + RadiusAdd local OrbitTime = GameTime * Speed MovingPart.CFrame = Orbit.CFrame * CFrame.new(Vector3.new(math.cos(OrbitTime), 0, math.sin(OrbitTime)) * ActualRadius) end RunService.Heartbeat:Connect(function(dt) GameTime += dt UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, workspace.MovingPart, workspace.Orbit) end)