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 kingcoyote · Nov 28, 2014 at 11:24 PM · vehiclepathfollowingbezier

Best way to have vehicles follow a path?

I am making a game that has AI controlled vehicles drive around some roads, completely autonomously, but I'm having a very difficult time getting the movement to be smooth and look natural.

They key things the vehicles need to do are:

  • Follow a road that has some turns and curves as it goes around hills

  • Slow down, stop, wait for other vehicles, and then accelerate through a stop sign

  • Slow down if a vehicle is stopped in the road

Initially, I found a SplineController library that did #1 very well, #2 okay and did not do #3. I tried modifying the library, but found it to be very convoluted and wrote my own using WheelCollider and RigidBody component to accelerate and steer, using a custom set of waypoints to define the road.

This had problems because the physics of the WheelCollider and RigidBody were too accurate, and these roads are stylized and simplistic and have some turns that are too sharp for them to handle.

I replaced the RigidBody and WheelCollider with a CharacterController that ignores physics, but the steering is very jerky or awkward and does not look natural. I tried to calculate out the correct turning and realized I'm basically mimicking a bezier curve.

I looked through the Asset Store a little bit to find things related to vehicles or rails or splines, but nothing stood out as the right fit, and I don't want to just drop $10 on hope.

Is there a way to easily do what I am trying to do? I'm willing to spend a little money on assets if that solves this problem.

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

2 Replies

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

Answer by kingcoyote · Apr 02, 2015 at 06:35 PM

I ended up using the SuperSplines library in the Asset Store and it worked great. I was able to define splines and have the vehicles follow the splines. I had to add in some extra logic around the intersections for the yielding, but that was easy enough to do.

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
avatar image
0

Answer by static_cast · Nov 29, 2014 at 02:14 AM

This is a great question for the unity forums, but I'll put my two bits here...

Make some waypoints in an array that tells it what to do.

Example (which is slightly similar to what you did):

 [location, speed, curve]
 [(0,1),50mph, true]
 [(1,2),50mph, true]
 [(1,3),30mph, false]

There ya go! :)

Also take a look at this: http://answers.unity3d.com/questions/386662/how-to-create-waypoints-for-a-car-to-follow.html

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 kingcoyote · Nov 29, 2014 at 06:10 AM 0
Share

Thanks for the answer, but like you said, that's essentially what I did. Simply saying "curve" is like telling a wordworker to just "cut the wood". Calculating that curve is fairly complicated and eluding me. The rads per sec will vary based on a few factors - distance to the waypoint, angle difference between the start angle and final angle (and how is that deter$$anonymous$$ed? line from start to end? tangent from end to end+1?), even speed has a factor (less rads per sec in a slow speed intersection than a high speed curve).

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Move along a run-time generated path of varying length at a set speed. 1 Answer

Recommendations for a script/plugin for creating set, curved paths 2 Answers

Bezier Path considering external forces 2 Answers

Having difficulty with Parent Object rotation and Child Object movement. 0 Answers

MoveTowards on paths, different speeds 1 Answer


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