So I’ve been making a game involving wands and for the wands I need to make a zig zag projectile. I know this topic is said before but how would I achieve this “random” zig zag effect with sine waves? A example of a zig zag projectile is in the game “Ro-Wizard” or “Magic Training”.
I am not sure why you want to do this with sine waves, as if you want a random zig zag you could just use math.random() to generate the height of the wave, and it will give you a random value. A sine wave should give you a periodic motion as it itself is periodic, unless you use math.sin() with a random value for the wave height. Can you tell me why you want to do this with sine waves, If you want a sinusoidal motion, then that makes sense, but for random it is strange.
I’m just conflicted. On 2 posts that I saw about zig zags, they used a sine wave to make the zig zag effect. This was confusing to me because using sine waves for zig zags is kinda weird. I also saw a few more posts that use math.random to calculate a offset, so I was kinda confused and conflicted.
That is interesting, I don’t know why they would sine waves for this but if I were to assume, it would be because math.random(-1,1) returns only whole numbers. And using math.sin(math.random(0,100)) they could have added decimals in that way. It does not really matter but how I would do it is with math.random()*2-1, as that will return a random value in-between -1 and 1. Though that mostly returns even numbers. It depends on what flavor of random you want. Both the methods should work for giving you a random zig zag, but it would be interesting to see if there is any difference between them.
What were the other two posts that talked about this?
Does anyone have any idea what projectile method is used in Magic Training wands? - #21 by Manelin and
Now, I know the second one shows a example with a projectile that is obviously made with a sine wave, but I want to know how she got her end product, which is clearly not a sine wave.
Truth be told I don’t either, she says she is using:
game:GetService("RunService").Heartbeat:Connect(function()
projectile.CFrame *= CFrame.new(0,math.sin(tick()*100),0)
end)
But this is to much like a sin wave in my testing and does not look like what her trail looks like, mine looks to regular. It may be she is using some 3d movement back and forth aswell in addition to this to make it more irregular. On closer inspection it looks as if she is using inconsistent speed of her particle as well, which might make it so it is more inconsistent. I’m sorry I couldn’t be of more help, you might be able to message her and she can explain more. I recommend trying different methods out, combining them, and stripping some out; then seeing which one works for you.
Can you elaborate on 3d movement and inconsistent trails?
By 3D movement I mean moving more than just up and down, it appears her spell bolt (?) moves side to side and up and down. The inconsistent trails, rather said inconsistent speed looks interesting, but if you look closely, if the bolt goes far up, it moves less forward.
Here you can see the bolt seemingly moving at different speeds particularly on the large jerk upwards at the end.
here you can see the bolt seemingly move in a loop, showing that it is moving side to side and also going forward.
My current problem with how this is done is how you get a long spell bolt to not randomly wiggle itself off center, but that should be fixed with some distance away from CenterPoint math. I believe in you!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.