Need Help with Raycast Projectiles

I need help with creating a Harry Potter wand system like this where the projectiles move in a zig-zag/swirling type of movement. I’m familiar with RayCasting and I’ve managed to launch projectiles but I still can’t find an efficient way to get the motion I want (without messing up the end position too), any support will be helpful. (I’m trying to avoid tweens as I am using FastCast / RayCast)

2 Likes

Making it wiggly usually involves a sine-wave. Using a graphing calculator can be pretty good in order to find what coefficients will be needed to make sure it hits the correct spot. not exactly sure how you would add that, but hopefully it gives you some form of a start.

1 Like

They probably do something like this after the projectile has been launched

game:GetService("RunService").Heartbeat:Connect(function()
       projectile.CFrame *= CFrame.new(0,math.sin(tick()*100),0)
end)

Its a pure guess but thats one way of doing a swirling effect

4 Likes

Thanks! This works very well! It helped me achieve more of a lightning look

https://gyazo.com/6a99e5b1c330af36e7ec5f9bcf084256

1 Like

how would i script this to where it sin waved and following the player’s mouse too?

nevermind i figured it out, thanks for the help!

1 Like

I do have one more problem though. The only way I can get it to be sharper is if I turn the tick * number to 100 or more. The problem with this is that it makes the zig zag very un-wide. And if I try turning the number down it makes the zig zag look wider but more like a smooth wave instead of a sharp zig zag. Is there any way I can make the zig zag wider while still keeping it’s rough lightning like shape?

you just multiply out of the parentheses

game:GetService("RunService").Heartbeat:Connect(function()
       projectile.CFrame *= CFrame.new(0,math.sin(tick()*100)*2,0)
end)
1 Like

when i go above two it goes crazy, like it doesnt look like a zig-zag anymore