How to make visual bullet follow raycast bullet path?

Soo, it’s only question about math mostly, is there any way to make that visual bullet that may use physical velocity or lerping can follow raycast path in an arc? I know that i can use beziers, but they wouldn’t be that effective for that many bullets

No, i don’t want to use any pre-made module, i know fast cast but i want to do it myself

I mean, technically, if you want to make a working bullet, then you could do the raycasting and damaging stuff in a server script, and make an independent bullet “visual” local script.

local handle = script.Parent.Handle
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local gun = script.Parent



gun.Activated:Connect(function() 
	
		
		local bullet = game:GetService("ReplicatedStorage").Bullet:Clone()
		bullet.Parent = gun
		bullet.Velocity = mouse.Hit.LookVector * 1000
		bullet.Position = handle.Position
		bullet.CanCollide = false
	

end)

EDIT: this would be an example, where the bullet flies straight forward. you can play with the .LookVector * 1000 a bit. It might fly in a bit of an arc if you lower the lookvector factor

Problem is that i want this visual bullet to be correct, and follow similar path, also raycast is in arc too! soo there is this problem

Maybe you can use a parabola for that?
I don’t know all that much about raycasting but changing one of the values to an adjusted parabola could work

Edit: I kinda forgot to mention that a parabola is the following:
f(x) = x * x
or
y = x * x

1 Like

I know it, problem is that it wouldn’t work as raycasts are dropped every point by some level, i wanted to ask also if player could see difference if actual bullet doesn’t hit target?

If that question is regarding to the script that i sent you, then IDK. Personally, I added a local script into the bullet that fires a remote event on impact. Theres a damage script that checks for that remote event to fire.

I know it isn’t really the best way to do it but yee…

There will only be a small “delay”, because ping exists

After experimenting with lerp parabola seems realistic soo yea, thx

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