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
6
Question by davidgraeme · Apr 30, 2013 at 09:12 PM · followsplinerail

Moving a GameObject along a Custom (Curved) Spline

Hi guys, After having extensively searched unityAnswers, the forum, the internet... I can't seem to find the solution to what I'm sure is a very simple problem.

I'm trying to make a 3rd person on-rails shooter. Really simple - a GameObject following a long spline that will curve at points, go straight at others, incline, decline etc. Like one can easily do in modelling software like Cinema 4D.

I found a few people that had asked this question, but never a conclusive answer. In my search I found the Spline Controller on the Unify Wiki (http://wiki.unity3d.com/index.php?title=Spline_Controller). But from what I can work out it only handles straight splines?

This must have a simple solution, they were doing this all the time in the 90s!! :) Thanks in advance to anyone willing to share some wisdom with me, really appreciate the help.

Comment
Add comment · Show 4
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 zombience · Apr 30, 2013 at 09:14 PM 1
Share

stop me if you've already heard this one, but have you investigated itween for unity? it has path movement and sounds like what you'd need

http://itween.pixelplacement.com/documentation.php

avatar image davidgraeme · May 01, 2013 at 06:03 AM 0
Share

Thanks for the reply zombience , I did actually read about it on a forum but the person was dismissing it as being performance heavy and useless when it came to iOS so I didn't look into it any further. Do you have any experience using it?

Edit: I see that iTween is only for C# development? What a shame, it looked great.

avatar image Fattie · May 01, 2013 at 07:21 AM 2
Share

FWIW

here's the simplest possible way i've ever been able to write routines to calculate equidistant points (actually approximately equidistant) and the tangents of those, along a cubic bezier:

 float bezierPoint(float t, float a, float b, float c, float d)
     {
     float C1 = ( d - (3.0 * c) + (3.0 * b) - a );
     float C2 = ( (3.0 * c) - (6.0 * b) + (3.0 * a) );
     float C3 = ( (3.0 * b) - (3.0 * a) );
     float C4 = ( a );
 
     return ( C1*t*t*t + C2*t*t + C3*t + C4  );
     }
 
 float bezierTangent(float t, float a, float b, float c, float d)
     {
     float C1 = ( d - (3.0 * c) + (3.0 * b) - a );
     float C2 = ( (3.0 * c) - (6.0 * b) + (3.0 * a) );
     float C3 = ( (3.0 * b) - (3.0 * a) );
     float C4 = ( a );
 
     return ( ( 3.0 * C1 * t* t ) + ( 2.0 * C2 * t ) + C3 );
     }


The four values, C1 C2 C3 C4, are sometimes called the coefficients of the bezier. (Obviously, you could just separately calculate those one-time if you feel like it.)

The factors a b c d are usually called the four "control points" for a bez.

Of course, t runs from 0 to 1, say every 0.05. "t" is conceptually like time as you move along the bezier.

If you are working in two dimensions, simply call the whole thing with all the X values to get the X result, and separately, with all the Y values for the Y result. In three or more dimensions again simply call the whole thing once for each dimension.

avatar image Graf-Zorba · Apr 20, 2015 at 03:40 AM 0
Share

I am working on a project with the same concept as described above, yet I want the player to be able to move the object/camera forward and backward along the path . $$anonymous$$any of the solutions posted here seem to be more suitable for an animated camera flythrough. I'd be very happy if someone has a hint on this.

3 Replies

· Add your reply
  • Sort: 
avatar image
9
Best Answer

Answer by Graham-Dunnett · Apr 30, 2013 at 09:15 PM

http://wiki.unity3d.com/index.php/Hermite_Spline_Controller

The screen shot on this page shows curved splines, so I don't think it's straight splines only. Alternative, visit Google and enter:

site:u3d.as spline

and hit the search button. You'll get loads of solutions. Perhaps your extensive search was faulty? ;-)

Comment
Add comment · Show 4 · 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 davidgraeme · May 01, 2013 at 05:59 AM 1
Share

Well I have to admit I am a little embarrassed as Hermite looks like a great solution. I blame my n00by lack of confidence :-) so from one Graeme to another (Graham), thanks so much.

avatar image Fattie · May 01, 2013 at 07:10 AM 0
Share

that's intriguing about the "u3d.as" idiom ... does that mean the site is "registered" in some way with google, that google knows that abbreviation? Good one

avatar image davidgraeme · May 01, 2013 at 11:17 AM 2
Share

Hey fattie, that's something I can help you understand - I'm an SEO :-)

site: is a search operator that filters your search so that Google only returns results for your given keyword that are hosted on the given website. As Graham illustrated the syntax is like so: site:domain.com keyword So yes u3d.as, the unity asset store, is "registered" with Google in a way: The pages hosted on the domain have been crawled and indexed by Google, and therefor show up in search results.

Hope this helps!

avatar image demented_hedgehog · Jan 22, 2015 at 09:35 AM 0
Share

SEO = Search Engine Optimizer (save you having to look it up if, like me, you didn't know :)

avatar image
0

Answer by Fattie · Jan 22, 2015 at 09:48 AM

hey David if you're still looking at this,

the absolutely perfect solution is

https://www.assetstore.unity3d.com/#!/content/2110

there are a number of competing packages on the asset store. we bought them all and that's the best one.

"This must have a simple solution" ... by no means. it takes expert programming in a number of fields and mathematics. we have lots of code base for mesh extrusion, splines etc but it's the sort of thing where it's much. much more intelligent to just use an existing proven package.

with that package (or indeed the competitor packages), the job is done. hope it helps

Comment
Add comment · Show 1 · 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 congtrungvnit · Nov 18, 2016 at 03:47 AM 0
Share

Hi. I'm looking at that extension. Do you know how to use it with root animation? For example if I have a rolling forward animation, how can I make my model following a spline while rolling but still keep the root animation? Thank you!

avatar image
0

Answer by Koyemsi · Mar 05, 2018 at 12:04 AM

I've just tried a free asset called Surge that does the job. It has many cool features, not only splines but also tweens and others I haven't tried yet. https://assetstore.unity.com/packages/tools/utilities/surge-107312

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

17 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

Related Questions

How to follow a moving object by camera on a line ? 1 Answer

object on a spline following another object(superspline) 0 Answers

Camera rotation around player while following. 6 Answers

how to continue spline? 0 Answers

How to generate railings (roller coaster track) along the created spline? 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