Comments and answers for "moving linearly along a bezier curve"
http://answers.unity.com/questions/1162684/moving-linearly-along-a-bezier-curve.html
The latest comments and answers for the question "moving linearly along a bezier curve"Comment by joshua-lyness on joshua-lyness's comment
http://answers.unity.com/comments/1162888/view.html
Yea that is right, however if I have a network of roads, perhaps total length of 10km, which isn't too much if you think about simcities roads, to get smooth movement, the cars would need 1/10th of a metre positions to jump between. If however I did that on a larger scale, say every metre, I could then just lerp between those positions. I think we are both barking up the same tree here, I think that is the same as what you mean. Then on 10km of roads you would have about 10,000 vector 3 positions, which is pretty little when you think about it ;)Wed, 30 Mar 2016 00:52:36 GMTjoshua-lynessComment by Eno-Khaon on Eno-Khaon's comment
http://answers.unity.com/comments/1162887/view.html
If you just do a little bit of ahead-of-time calculation of the points along the curve (i.e. dividing it into 100 points, or even 1000), keeping data on those would only really have that initial overhead.
Keep an array for 1000 Vector3 values and 999 float values (for the distance between each pair of vertices) and you'll still have set aside less data than many single character models' vertex positions.Wed, 30 Mar 2016 00:43:24 GMTEno-KhaonComment by joshua-lyness on joshua-lyness's answer
http://answers.unity.com/comments/1162721/view.html
Ahhh i was hoping that wasnt the case. :/ oh well
An idea i thought up while i was munchin on my tea is actually not a bad one
Lets say i have a resolution of 0.01t, which is how often im sampling the distance from the start of the curve. What i have is an array of 100 floats, representing the distance i am along the curve at different t values.
The whole point of this is for moving cars along a cubic bezier. So imagine i have a car that moves at 2 m/s, and is currently 50 metres along the curve. If i do 50 + 2 * time.deltaTime i can find the position the car will be at next frame. So lets pretend thats 50.4.
Now when i sample t's distances, i mightve got 50.21 and 51.05, for example. My original idea was to round 50.4 to the nearest sampled distance and use that t value, but then next frame i might jump to 51.05 and itd look a little weird.
So my new idea is that in this array of distances, i get the t values of both 50.21 and 51.05 metres, and lerp that by the ratio of 50.21 to 50.4 to 51.05.
This will give me smooth movement, even if it isnt really accurate. Itll do. :)
What this also means that if i want to do this on a lower end PC, i could sample distance every 0.01t or something similar instead, and because we are lerping the distance itd still look smooth.
Ill try this method anyway.Tue, 29 Mar 2016 17:29:17 GMTjoshua-lynessAnswer by Eno-Khaon
http://answers.unity.com/answers/1162703/view.html
You're on the right track.
To take a note from [a great source on Bezier curve information][1],
> there is no generic formula that
> allows you to calculate the arc
> length.
With this in mind, a good enough approach is to break down the curve into points, whether at roughly-equidistant or arbitrary lengths, then interpolate between the nearest points on each side of your target.
Unfortunately, there is no inexpensive, perfect solution to this problem, but if perfection isn't absolutely necessary, you can still get indistinguishably close through quicker calculations than you might expect.
[1]: http://pomax.github.io/bezierinfo/Tue, 29 Mar 2016 17:05:17 GMTEno-KhaonComment by Owen-Reynolds
http://answers.unity.com/comments/1162696/view.html
This is just a math question. You're asking if Bezier curves (those are x^2 splines, right?) can be rewritten as f(t)=(x,y). I think the answer is no, but a math forum (or just Wikipedia) would have more of an answer (that's where I think I saw the "no" answer.)Tue, 29 Mar 2016 16:55:04 GMTOwen-Reynolds