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?
Use LinearVelocity 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 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.
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?
Not exactly 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:
(Make sure to toggle off the CanCollide, and Anchored properties!
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
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!
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