Orbiting a part around something on different planes

How can make a part orbit something, like a player, on different planes, and not just on one (like a solar system), without changing the rotation of the part it’s orbiting?

I wanna achieve this exact effect that you see here in the first seconds of this video:
SPHERE SHIELD AURA!!! - Build a Boat ROBLOX - YouTube

After messing around, I did something similar, but I did it by changing the rotation of the center part and it doesn’t really move around the player like in the video.

Code
local part = script.Parent
local center = workspace.anchor

local RunService = game:GetService("RunService")


local radius = 5
local radians_per_sec = math.rad(200)
local angle = 0

RunService.Heartbeat:Connect(function(deltaTime)
	angle = (angle + deltaTime * radians_per_sec) % (2 * math.pi); 
	--multiplying it by deltatime to ensure it happens over the course of one second
	

	local x = math.cos(angle) * radius
	local y = math.sin(angle) * radius
	local z = 0 * radius

	local new_pos = Vector3.new(x, y, z)
	
	center.CFrame = center.CFrame * CFrame.Angles(math.rad(45*deltaTime), 0, 0) --[How can I achieve the same effect as the video without doing this]
	part.CFrame = center.CFrame * CFrame.new(new_pos) 
end)

Here’s the result: https://gyazo.com/f44a343e62949b65e64a327c12dddd72 I know, it moves slower but I’m more focused on the orbit pattern like in the video

As you can see, it’s orbiting on different planes because the center is rotating, but I don’t want to manipulate the center part. I want to manipulate only the part that’s orbiting, and I want it to move like in the first video I linked. How would I do this?

You can make it using a bit of CFrame manipulation:

-->> Services
local runService = game:GetService("RunService");

-->> References
local orbit = workspace:WaitForChild("Orbit");
local orbitter = workspace:WaitForChild("Orbitter");

-->> Functions & Events
local orbitAngle = 0;
local orbitSpeed = 5;
local orbitDistance = 10;
function Update(dt)
	orbitAngle += orbitSpeed*dt / 2 * math.pi
	orbitter.CFrame = orbit.CFrame * CFrame.Angles(0, orbitAngle, 0) * CFrame.new(0, 0, -orbitDistance)
end;

runService.Heartbeat:Connect(Update)

This is what I said I didn’t want. The script you gave me is just an orbit on one plane. I’m trying to make it on multiple planes, like in the first video I linked

This code implemented what the video showed:

-->> Services
local runService = game:GetService("RunService");

-->> References
local orbit = workspace:WaitForChild("Orbit");
local orbitter = workspace:WaitForChild("Orbitter");

-->> Functions & Events
local orbitAngle = 0;
local orbitSpeed = 0.9;
local orbitDistance = 10;
function Update(dt)
	orbitAngle += orbitSpeed*dt / 2 * math.pi
	orbitter.CFrame = CFrame(orbit.CFrame.Position) * CFrame.Angles(0, orbitAngle, 0) * CFrame.Angles(orbitAngle*15, 0, 0) * CFrame.new(0, 0, -orbitDistance)
end;

runService.Heartbeat:Connect(Update)
1 Like

Think the one you got is way better than that video. It don’t looking like that one is totally just rotating. More of it ends up rotating while darting around line point to line point.
pic2

Or maybe something is spinning around and the line is set to head towards where it is at that moment. As the spinning thing is still moving.

1 Like

I just wanna know if there is a way I can do what I just did, but without manipulating the center part and only just controlling the position or cframe of the part that’s moving. Say if I were to have like magical orbs orbit a player…if I did it the way I attempted, I’d have to put some invisible part in the player and then weld it to like the HRP and idk…it just doesn’t seem like the most efficient way to me.

you could put the values you need but dont want to edit on the center part into variables and change that, so you’d treat the variables as a part

I don’t understand what you mean ;-;

you would calculate something with the centerparts cframe, so just store the cframe and change that instead of the centerparts cframe

I don’t want to use the center part at all. I just want to change the part that’s orbiting.

And even then, your method did not work. I stored the cframe of the center part, and added it onto the cframe of the part that’s orbiting after adding onto the stored center cframe using CFrame.Angles, but I still get a regular one plane orbit because it’s actually adding onto the part’s CFrame and not the center.

That thing is moving pretty fast … don’t see how you would do this without some type of center rotating. You’re pretty demanding for someone that can’t do it yourself. This is Script Support, helping you with your script. Not demand a script, I don’t see your scripts at all. Clearly you actually have no clue how to do this yourself. Yet you demand how it should be done. How about you go with the people that wrote you scripts, that understand how this is being done.

This is precisely what I needed! Just one question though if you can answer, which will help me from now on: What exactly is the difference between adding those CFrames.Angles separately as opposed to doing something like

CFrame.Angles(orbitAangle*15, orbitAangle, 0)

There is a difference for sure; something I’m definitely gonna read more about. I was not at all aware of this difference so ty!

Like I said before, I am not looking to match the speed, only the pattern of its movement, which is how it’s orbiting on different planes. And yeah, that’s why I want to know if there’s a way to do this without a center rotating, and how I can do that. And did you not see my script that I posted?? In the expandable tab where it says Code ? I’m not being “demanding.” I’m simply trying to be explicit so that people know the details of my problem. Stop trying to start something plz.

But anyway, the problem is solved by @ComplexMetatable The first script he wrote was not what I was looking for, and don’t worry, I understood what he wrote in the first script, which is why I was able to tell him that it wasn’t what I looking for. However, the second script that he wrote was exactly what I wanted and I learned something new about CFrames from it. I never knew there was a huge difference. Here I thought I was going to have to use some more trigonometry or something ;-;.

1 Like

What are you talking about … it’s just changing it’s angle as it rotates. While moving at warp speed.
Most of that is while he is moving … and it could be coming out of both ends. Look towards the end of the video. You see two things hanging.

Yes, as it changes its angle as it rotates, it also begins orbiting on a different plane. The two things hanging do not matter, nor does the speed. Only the pattern of the movement.

It’s not changing plains there is no other plain. That pattern is coming for the way it’s updating
Like I said … If you had something on the end of a “rope” rotating around. Then had a point head to where it is ATM while it keeps moving. Then heads for where it is again ATM in intervals you would get the same exact pattern. No matter what you want, this is coming from a rotation.

This is an attempt to draw what I meant:

It’s not the best drawing, but those rectangles u see are the planes I am talking about and if you sort of imagine it in ur head, u can visualize the orb following the outline of one plane to the next plane. Both of us are not wrong.

Looks like a valid attempt … however it’s STILL a rotation on the objects the “orb” would be going to point to point. We are saying the same thing.

not sure I understood what u said, but ok! The topic is resolved and now it’s time for me to read more on cframes

Just like the video … now attach it to your head.
Make sure to lock and anchore the orbitter’s
pic2

local runService = game:GetService("RunService");

-->> References
local orbit = workspace:WaitForChild("Orbit");
local orbitter1 = workspace:WaitForChild("Orbitter1");
local orbitter2 = workspace:WaitForChild("Orbitter2");

-->> Functions & Events
local orbitAngle = 0;
local orbitSpeed = 10;
local orbitDistance = 10;
function Update(dt)
	orbitAngle += orbitSpeed*dt * math.pi
	orbitter1.CFrame = orbit.CFrame * CFrame.Angles(0, orbitAngle, 0) * CFrame.new(0, 0, -orbitDistance)
	orbitter2.CFrame = orbit.CFrame * CFrame.Angles(0, orbitAngle +1, 0) * CFrame.new(0, 0, -orbitDistance)
end;

runService.Heartbeat:Connect(Update)

use orbitAngle and orbitDistance to get it to do different types of orbits.
Just don’t like using Heartbeat

robloxapp-20220701-1646286.wmv (83.5 KB)