Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by TwixEmma · Feb 13, 2013 at 08:25 PM · pathalgorithm

How to move an object linearly along a bezier spline

Hi, I am creating a bezier spline implementation that works via the DeCasteljau algorithm, the algorithm works as intended, but the tessellation (spacing between points produced by the curve algorithm) isn't linear. In order to move a vehicle or object along the path at a consistant, controllable speed in runtime I need a way to either change the tessellation whether by another algorithm or a helper function. Does anyone have or know anything that can help me? My curve system has nodes, each node consists of four transforms, pointA controlA controlB and pointB, the algorithm returns a point from a to b using the control points to define the curve. Any help will be appreciated, I've done so much research my head hurts so I need some help, thanks.

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 OmarAlhaddad · Feb 14, 2013 at 08:10 AM 0
Share

i had a similar issue but i was using the iTween library, if you want you can check that out, and specifically for your question check out the iTween.PutOnPath function, might give you some ideas.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by nullstar · Feb 14, 2013 at 02:36 PM

The basic technique is, as a pre-processing step, to evaluate your curve for lots of small steps of your input parameter. With each step evaluated calculate the distance between the point returned and the previous point returned and add this to a total distance variable you keep track off as you go along. Then put all these distances and corresponding input values for each distance into a table and store this table somewhere.

When your game is running you can keep track of a distance variable for each object that is following the spline which you store inside your object. Each update you then increment the objects distance variable according to its speed and then look up this distance in your table you pre-calculated earlier to figure out the appropriate input value for your curve. To get the position of your object you then evaluate your curve using the looked up input parameter.

This will allow your object to move along the spline at a constant speed.

What I've described above is a quick overview of the technique. For a more detailed discussion with associated maths, take a look at this tutorial I wrote for shmupdev a while back. Unfortunately the pictures are now missing since the site got archived and the tutorial deals with catmul-rom splines rather than bezier but you should be able to work it out. Just replace the catmul-rom equations for your bezier equations and the rest should be exactly the same.

I hope that helps.

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

the specified path is not of a legal form 1 Answer

how do I add abilities(Scripts/GameObjects) to my path finding agent 1 Answer

Start/End zigzag coverage region algorithm 1 Answer

How can i loop my path instead of it ending on the lasat point 1 Answer

Waypoint Setup: How? 4 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