I already researched a lot but none of the solutions that i can find seem to work. The distance between p0 and p2 is decided by how far the MousePosition (p2) is away from p0. Yet, how would i make it so that, no matter what the distance is, it always takes the same time (say for example, 5 seconds) to get from p0 to p2?
You could use magnitude between the 2 points to get the distance in straight line, then divide that by the time you want it to take to get the wait time per second/millisecond.
local distance = (p0-p2).magnitude
local timeToTake = 5 -- seconds
local waitTime = distance / timeToTake
local steps = timeToTake * 10
for t = 1, steps do
-- bezier positioning here.
task.wait(waitTime / steps)
end
Edit: Made some fixes to the logic. I think this might work, didn’t test it though.
Your code already does this, the number of steps in your for loop and your wait time is always the same. If you want the snowball to fly longer then just make your step smaller… Unless I’m not understanding your problem correctly
Look, my problem is that if i click very close to my player and the ball goes there, it takes very long. However, when i fire in the air or something, it goes really fast. Also when the further away i click from my character, the faster the projecile goes. How would i balance this?
So instead of taking the same amount of time to get from A to B, you want it to go the same speed regardless of distance? That’s different than what you suggested in the OP.
Thanks, the result is that the part basically has a delay or so, and then suddenly it teleports to the mousePos (probably after the 50 steps). So, still not what i want.
Alright, how would i handle the BodyVelocity (i really suck at velocity)? I’m basically trying to make a snowball, so it has to go up a bit and down a bit