[Help!] BodyVelocity in one direction with curve

Hello :raised_hand:, I am creating a beam that goes directly to where the mouse is pointing. Everything was going well until I came up with the idea of adding a curve to the beam. I want the beam to travel in the same direction but with a slight curve. I have been researching various sources about “curves” and even checked similar scripts with a similar idea, but the beam seems to curve in a different direction. I want the beam to have the same slight curve no matter where I point my mouse.

The red line represents the direction I want, which corresponds to where the mouse points.

image

Script (what i was trying):

local function BlastCurve(Character,MouseHit)
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
	
	
	local Ball = script:WaitForChild("KiBlast"):Clone()
	Ball.Parent = workspace:WaitForChild("Debris")
	Ball.Parent = Debris_Folder
	Ball.CFrame = HumanoidRootPart.CFrame
	Ball.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,0,0)
	Ball.CFrame = CFrame.new(Ball.position, MouseHit) + CFrame.new(Ball.position, MouseHit).LookVector * 5

	
	local vel = Instance.new("BodyVelocity",Ball)
	vel.Velocity = Ball.CFrame.LookVector * 80
	vel.MaxForce = Vector3.new(1e6,1e6,1e6)
	vel.Parent = Ball
	
	
	spawn(function()
		
		while true do
			vel.Velocity = vel.Velocity - Vector3.new(2,0,0)
			wait(0.01)
		end
	end)
end

I use a translator, btw.

If I may why are you using parts to make a beam? Why not use the default roblox beam system?

Sorry, it’s my translation. I want to make a ki attack, similar to a dbz ki blast. Using a part

Can you provude us with a video of what you want and what it does?

i have a picture, the red line is as I wish
image

I do understand you have a image but one image isnt enough to understand the motion of the spheres.

Sorry bro, but I don’t have a video to demonstrate exactly how I want it. What I’m looking for is to make the sphere move directly towards the position of the mouse cursor using “BodyVelocity” while adding a subtle curve to its path (similar to the shape of the red line in the image I sent you).

OOH I think I know what you’re looking for! I think you may want to use Bezier curves for this. Usually, the modules that provide such functionality return a list of points, to which you could move the projectile to, example of the movement velocity would be:
CFrame.lookAt(proj.Position, bezierPoint).LookVector * 100

You just loop through the list of the points with a certain delay between moving to each and it should work, I believe.

A search on the devforum should provide you some bezier curve modules to work with.

I think another way to do this is parabola

local a = HumanoidRootPart.x-mouse.hit.position.x
local z = HumanoidRootPart.z-mouse.hit.position.z
-- parabola: y=(z/(a)^2)x^2
-- line: y= (z/a)x
local x= 0
while x< a do
      local pointoffset =(z/(a)^2)x^2
      local attachment.position = vector3.new(x+HumanoidRootPart.x,somerandomY,HumanoidRootPart.z+pointoffset)
      x += 1
-- align position to attachment position
end

only tested on graphing calculator and bad at math, but I believe it should work.

Yes, I did some research on Bezier curves, but decided to use BodyVelocity, because with “Bezier curves” I noticed that the fireballs had different speeds depending on where the mouse was pointing. For example, when I aimed further, the fireball became extremely fast, while when I did the opposite, the speed decreased.

https://gyazo.com/7937fb3566e1d68b7bf53321afd3f479

I want the fireballs to have the same speed and move in the direction I want (where the mouse is pointing).

That’s why I mentioned to use something around CFrame.lookAt(proj.Position, bezierPoint).LookVector * 100 as the Velocity of a BodyVelocity, it’d ensure that the velocity is constant no matter the distance.

I already put your script, but I don’t know what to do now

local Debris_Folder = workspace:WaitForChild("Debris")

local function Ball(Character,MouseHit)
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
	
	local Ball = script:WaitForChild("KiBlast"):Clone()
	Ball.CFrame = HumanoidRootPart.CFrame
	Ball.Parent = Debris_Folder

	local function Curve(t,P0,P1,P2)
		local A = P0:Lerp(P1,t)
		local B = P1:Lerp(P2,t)
		
		return A:Lerp(B,t);
	end
	
	local Mid = (HumanoidRootPart.Position - MouseHit.p).Magnitude
	
	local Part0 = HumanoidRootPart.Position + Vector3.new(0,0,-3)
	local Part1 = (HumanoidRootPart.CFrame * CFrame.new(-Mid/4,Mid/4,Mid/4)).p
	local Part2 = MouseHit.p

	
	--for i = 0,1,0.045 do
	--	local Bezier = Curve(i,Part0,Part1,Part2)
	--	Ball.Position = Bezier
	--	task.wait()
	--end
	

	local vel = Instance.new("BodyVelocity",Ball)
	vel.Velocity = CFrame.lookAt(Ball.Position, MouseHit.p).LookVector * 100
	vel.MaxForce = Vector3.new(1e6,1e6,1e6)
	vel.Parent = Ball
end

I do not recommend BodyVelocity, as it is deprecated. Consider using LinearVelocity or AlignPosition instead.

Could anyone help me please? i want to solve this

I mean you could try the a lot less realistic way of using a parabola… (Im bad at math and scripting that is the only thing I think of)