Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Mar 29, 2016 at 07:02 PM by joshua-lyness for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by joshua-lyness · Mar 29, 2016 at 04:30 PM · movementcurvebezierlinearcurved path

moving linearly along a bezier curve

Ok so I had an idea for a way of moving linearly along a Bezier curve. I thought that if you plot a graph (in real life) that compares the value of t to the actual length you are along the curve, you could move linearly along the curve. For example, lets say I had a cubic Bezier curve that was 10 units long. Now if I increase t every frame by 0.01, I would end up with non-linear movement (it would move quicker at some parts of the curve than others.) So if I plotted a graph, every 0.01t along the curve, that returns the distance I am along the curve, I could feed in a distance, and get back a value of t. That means that to move linearly, I would increase the distance every frame, return a value of t, and then move to that value of t. Linear movement! Only problem is, lets say I am at a distance that wasn't sampled on the graph, how would I get a t value? sort of like interpolated between the points? Its a tricky idea, and I'm sure there are a lot of reasons why this idea is flawed, but so far it seems like the only solution you really have. The only solution I could think of is sampling the curve at ridiculous resolution, ie every 0.001t, and then round the distance to one that is sampled at this t value. however that means that things will jump along the curve. but its the only solution so hey ho. :/

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Owen-Reynolds · Mar 29, 2016 at 04:55 PM 0
Share

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.)

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Eno-Khaon · Mar 29, 2016 at 05:05 PM

You're on the right track.

To take a note from a great source on Bezier curve information,

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image joshua-lyness · Mar 29, 2016 at 05:29 PM 0
Share

Ahhh i was hoping that wasnt the case. :/ oh well An idea i thought up while i was munchin on my $$anonymous$$ 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. $$anonymous$$y 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 ins$$anonymous$$d, and because we are lerping the distance itd still look smooth. Ill try this method anyway.

avatar image Eno-Khaon joshua-lyness · Mar 30, 2016 at 12:43 AM 1
Share

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.

$$anonymous$$eep 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.

avatar image joshua-lyness Eno-Khaon · Mar 30, 2016 at 12:52 AM 0
Share

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 ;)

Follow this Question

Answers Answers and Comments

44 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

High speed sliding (ski/sled) from curved slopes in a 2d game. 0 Answers

How to move object in 45/30/15 degree arch. 2 Answers

2D upward curve movement? 0 Answers

Rotating animation at the same speed 1 Answer

Bezier curves with rotation 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges