Keep a part in the air without anchoring it

So im attempting to make a part that simply spins in place. Seems simple enough. I created an angular velocity to handle the spinning, but I cant seem to find a way to keep the part floating in air without it being unanchored. Anchored parts are obviously ignored by the physics engine so the velocity no longer works.

After some research I came across AlignPosition to set the part’s position to a SET value. The issue with that is that if I decide to make any changes to the position of my spinning part, I subsequently have to adjust the AlignPosition. In a bigger game with lots of spinning parts, doing that just isnt very sufficient and leaves room for human error.

Now, I could simply script the spinning myself by constantly updating the rotation instead of using roblox’s built in forces, which is a valid option, but Id like to minimize the amount of lines that are necessary for my game to be not only working but clean and tidy. So if prefer to just stick to using constraints instead of adding yet another script to my game that might not be needed.

Is there anyway to achieve this without code, or will I have to suck it up and code it manually?

Super dumb suggestion but have you tried using AlignRotation instead of rotating with AngularVelocity? It might not generate the result you want however. In that case you probably will have to script the rotation

I’m actually unsure if AlignRotation works along with a part being anchored but I guess you could give it a shot

By AlignRotation, i assume you mean AlignOrientation, which unfortunately doesn’t achieve the result. AlignOrientation does basically the same as AlignPosition, its a set value, but instead it forces a rotation. Id have to script the AlignOrientation to update the position. I appreciate the reply though!

1 Like

My bad, it’s a bit late so I guess I didn’t catch that mistake lol. Yeah you’re probably gonna have to script it yourself unless you find a workaround. Good luck with that!

2 Likes

If I were you, I would have a way to identify all of the spinning parts, such as a folder that has them as children or some table, etc…

Have a script that goes through all of them, and gets their position and then sets the align position, then sets the angular velocity.

So all you have to do while editing the place, is move the spinning parts where you want them, and keep them anchored, and the one time script will adjust their alignposition and unanchor and set their velocity.

1 Like

I ended up caving and switching to scripting it myself, using the method you suggested(Which was the method i was going to use anyways).

I’ll leave the script here for anybody who needs it in the future, though it may need some tweaking for their needs

local GEM_SPEED = 1 -- The rotation speed

-- Function generates the velocity and aligns the position
local function CreateGem(part: BasePart, speed : number)
	local attach: Attachment = Instance.new("Attachment")
	attach.Name = "Attach"
	attach.Parent = part
	
	local pos = Instance.new("AlignPosition")
	pos.Name = "Position"
	pos.Attachment0 = attach
	pos.Mode = Enum.PositionAlignmentMode.OneAttachment
	pos.Position = part.Position
	pos.Parent = part
	
	local velocity = Instance.new("AngularVelocity")
	velocity.Name = "Velocity"
	velocity.Attachment0 = attach
	velocity.AngularVelocity = Vector3.new(0, speed, 0)
	velocity.MaxTorque = math.huge
	velocity.Parent = part
end

-- Loop through folder of spawn parts
for _, spawn in workspace.Spawns:GetChildren() do
	-- Clone the part
	local gem = script.Gem:Clone()
	-- Set its initial properties
	gem.Position = spawn.Position
	gem.Anchored = false
	
	-- Call function with the provided part and speed
	CreateGem(gem, GEM_SPEED)
	-- Destroy the spawn part(optional for cleanup)
	spawn:Destroy()
	
	-- Add the new spinning part to the workspace
	gem.Parent = workspace
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.