Projectile Falling to Gravity

I want this part to continue on a straight line, unaffected by gravity.

I want to keep using vectorforce (in order to learn it) instead of tween or bodyforce, and I have tried setting the involved parts to massless but does not seem to do anything. You can see that it moves forward in the direction I want , but succumbs to gravity or whatever force is pulling parts down.

Here is the code

local projectile = game.ReplicatedStorage.Meshes.WindProjectile:Clone()
		projectile.Anchored = false
		projectile.CanCollide = false
		projectile.Massless = true
		
		local particleblock = game.ReplicatedStorage.VFX.Wind.WindProjectile1:Clone()
		particleblock.Anchored = false
		particleblock.CanCollide = false
		particleblock.Massless = true
		
-- Where I am defining the positioning of the parts
		local function Positioning()
			local offsetCFrame = CFrame.new(0,1,-5)
			projectile.CFrame = charahum.CFrame:ToWorldSpace(offsetCFrame)
			local current = projectile.CFrame
			new = current * (CFrame.new() * CFrame.Angles(math.rad(9),math.rad(-17.5),math.rad(-151.922)))
		end
		
		local function Positioning2()
			local offsetCFrame = CFrame.new(0,0,-10)
			particleblock.CFrame = charahum.CFrame:ToWorldSpace(offsetCFrame)
			local current = particleblock.CFrame
			new2 = current * (CFrame.new() * CFrame.Angles(0,0,math.rad(28)))
		end
		
		local slashTrack = Animator:LoadAnimation(animefold["Slash"])
		slashTrack.Priority = Enum.AnimationPriority.Action
		slashTrack.Looped = false
		
		
		hum.WalkSpeed = 0
		hum.JumpPower = 0

-- Setting the Positions
		Positioning()
		Positioning2()
		projectile.CFrame = new
		particleblock.CFrame = new2
		particleblock.Parent = projectile
		
		local weld = Instance.new("WeldConstraint")
		weld.Part0 = projectile
		weld.Part1 = particleblock
		weld.Parent = projectile
		
		local vekattach = Instance.new("Attachment")
		vekattach.Parent = particleblock

-- Here is the force
		local vel = Instance.new("VectorForce")
		vel.Attachment0 = vekattach
		vel.Force = Vector3.new(0,0,-1)
		vel.Parent = particleblock

		slashTrack:Play()
		slashTrack:AdjustSpeed(0.75)
		slashTrack.Ended:Connect(function()
			hum.WalkSpeed = 16
			hum.JumpPower = 50
		end)

		wait(0.4)
		projectile.Parent = workspace

RobloxStudioBeta_h0EdQXZNPG

1 Like

you could add an upwards force on the Y that corresponds to the gravity in game (workspace.gravity) or you could ditch the bodymover effect and use a cframe lerp or tween while anchoring ur part so it guarantees the part will reach the destination every time

2 Likes
local vel = Instance.new("VectorForce")
		vel.Attachment0 = vekattach
		vel.Force = Vector3.new(0,workspace.Gravity,-1)
		vel.Parent = particleblock

Just causes the projectile to rocket off into space. Are the body movers just not used in scripting this type of stuff? Should I just use tween always?

Yeah, usually people either tween it or use a while loop with a cframe lerp. It’s a lot easier and less over head because you don’t need physics for this yk

Yep, tween worked which I knew about already. I just wanted to learn about bodymovers, but since no one really uses them I guess there is no point. Thank you!

1 Like

Btw usually you will need to multiply by mass to get the antigravity force using part.AssemblyMass.

Just some more info.

1 Like

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