How would I make a part anchor in the air without anchoring?

Hey, I was wondering if I could make a basepart anchor in the air without the Anchored property enabled, I couldn’t achieve this without me using a deprecated body mover

Is this possible with a script? if so, could you help me out?

Thank you in advance! :DD

Use LinearVelocity :wink: It’s practically the same as a BodyVelocity, except you have to create an attachment for the Part to hook onto and set its MaxForce to math.huge, and the VectorVelocity to Vector3.new(0, 0, 0)

I can instruct it for you if you need the further assistance

I don’t think I’m understanding are you asking like

game.workspace.MyPart.Anchored = True

1 Like

Why would you need this functionality? What are you trying to achieve with this? If you can answer that question, there might be a better solution.


I recommend using AlignPosition to align an object’s position to a specified value.

no, I want to make it not anchored and have the functionality of an anchored basepart

I wouldn’t want to use AlignPosition because it would only local in 1 place, I’m trying to make a fireball throwing tool thingy, and I don’t want to use TweenService because it might be less performant. I want it to not have gravity so it doesn’t fall down and I can just add a VectorForce to make it move.

ooh okay, is LinearVelocity the same as AngularLinearVelocity?

Let me stop you there, you can do interpolations manually through Lerp and it will be faster than TweenService and faster than using physics with LinearVelocity.


BodyVelocity's replacement is LinearVelocity. There is no replacement for BodyAngularVelocity, and I don’t think AngularLinearVelocity even works.

A more performant solution, perhaps, is adding a vector force to counteract gravity, but the part has collision disabled.

So what you’re saying is to use Lerp to lerp the CFrame of the basepart and it will be faster than TweenService and LinearVelocity? Alright, I’ll use that, thank you!

Btw, how does a vector force counteract gravity? What if I have to change the mass of the model and it doesn’t help counteract gravity anymore, do I need to use a script to change the vector force’s force stronger?

(sorry for bad English btw :frowning:)

FloatingBlockTest.rbxl (45.5 KB)

image

local part = script.Parent

local cf = part.CFrame

local attachment = Instance.new("Attachment")
attachment.Parent = part

local alignPosition = Instance.new("AlignPosition")
alignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment
alignPosition.RigidityEnabled = true
alignPosition.Attachment0 = attachment
alignPosition.Position = cf.Position
alignPosition.Parent = part

local alignOrientation = Instance.new("AlignOrientation")
alignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
alignOrientation.RigidityEnabled = true
alignOrientation.Attachment0 = attachment
alignOrientation.CFrame = cf
alignOrientation.Parent = part


workspace.Position.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		alignPosition.Enabled = false
		workspace.Position.BrickColor = BrickColor.Red()
		wait(5)
		workspace.Position.BrickColor = BrickColor.Green()
		alignPosition.Enabled = true
	end
end)

workspace.Orientation.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		alignOrientation.Enabled = false
		workspace.Orientation.BrickColor = BrickColor.Red()
		wait(5)
		workspace.Orientation.BrickColor = BrickColor.Green()
		alignOrientation.Enabled = true
	end
end)
1 Like

Is the Part supposed to move around the Workspace, or in a straight line?
A PrismaticConstraint can be used for a platform type of movement.

Not exactly :sweat_smile: If you were referring to the AngularVelocity object, then somewhat, it does share Physics the same as LinearVelocity but it acts differently & rotates

Now something though to keep mind of, is that you have to decide which side (Client or Server) you want the Fireball to be created on

The best way to handle smooth transitions is preferably on the client, as it can easily be replicated onto your side whilst moving at a constant speed not affected by gravity at all but do keep in mind though that you’ll need RemoteEvents to handle the proper replication back and forth (Hit Detection, Damaging, etc)

Let’s start though by going ahead and creating our Fireball, to place inside ReplicatedStorage as that’s where we’ll be able to easily access our cloning from there:
image (Make sure to toggle off the CanCollide, and Anchored properties!

image

After we have that setup, let’s go ahead and create a LocalScript inside StarterPlayerScripts to handle our Fireball Projectile

Now, something to keep in mind is that we’ll have to create our Attachment (I think this is optional), and LinearVelocity within the client as handling it on the server (If we do ever have a LinearVelocity object already in place) would not properly replicate back to our side here

  • Step 1: Clone our Projectile, and .Parent it to the workspace
local Projectile = game.ReplicatedStorage.Fireball:Clone()
Projectile.Parent = workspace
  • Step 2: Create our Attachment, and .Parent it to our Projectile so we have an Attachment to hook onto our LinearVelocity when we create it:
local A = Instance.new("Attachment")
A.Parent = Projectile
  • Step 3: Create our LinearVelocity object, assign its properties to our desired locations, and .Parent it to the workspace
local LV = Instance.new("LinearVelocity")
LV.Attachment0 = A -- We hook this onto the Attachment we just created
LV.MaxForce = math.huge -- Set our "MaxForce" to math.huge so it doesn't conflict with Gravity
LV.VectorVelocity = Vector3.new(20, 0, 0) -- We can set this anywhere, but for now let's just set it to the X Axis
LV.Parent = Projectile

After doing everything, we should get a result of this!


Now of course this isn’t perfect, but it’s hopefully a head start to get started on how to create something with what you’re achieving here :wink:

Here’s the full script as well, I included a bit more features just to improve it a tad bit:

for Loop = 7, 1, -1 do
	print(Loop)
	task.wait(1)
end

local Projectile = game.ReplicatedStorage.Fireball:Clone()
Projectile.Parent = workspace

local A = Instance.new("Attachment")
A.Parent = Projectile

local LV = Instance.new("LinearVelocity")
LV.Attachment0 = A
LV.MaxForce = math.huge
LV.VectorVelocity = Vector3.new(20, 0, 0)
LV.Parent = Projectile

task.wait(10)

Projectile:Destroy()

Of course, if you have any questions do feel free to ask!

@SubtotalAnt8185 The alternative for BodyAngularVelocity is literally removing the “Body” part of it lol, AngularVelocity

I also wouldn’t exactly say that Lerps are better than Tweens, as it depends entirely on the use case here + I would presume attempting to constanty Lerp while having the Anchored property set to false would result in the Part having to conflict every so often with physics as it’ll keep attempting to fall down nonstop

5 Likes

Thank you for the long explanation! This really helped me :DD

1 Like

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