• 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 noodlz · Jul 02, 2013 at 11:55 AM · collisionaicarwaypointspline

Check whether car has passed a point in world space

Hello!

I'm developing a racing game and currently working on a reinforcement learner for my car AI. I got it working for an early version of my car prefab (had a fairly slow top speed of 60mph).

I have since updated my car prefab to have a higher acceleration and top speed (now 120mph).

Now for the problem:

The car is driving around the track based on points on a spline generated from several waypoints positioned around the track (throttle and steering values are learned over thousands of iterations between each point on the track).

This worked fine for the first prefab which had a relatively low speed; I was checking the magnitude of the vector between the car and the point and if this was under a threshold (ie 2.0), then move on to the next spline point.

Now the car is at a higher speed, however, this check is sometimes skipped as the car moves past it too quickly. As such it ends up crashing as it is still trying to steer/throttle towards the point.

I'm struggling to think of possible solutions to this. One potential one I came up with may be to create simple box colliders at each spline point with continuous dynamic collision detection and use that to check if the car passes through it, but I feel this may be a bit of a hacky solution.

Does anyone have any suggestions/encountered something like this before?

Sorry for the wall of text :)

TL;DR: Car moving too fast to check if it has passed through a point on a spline, how can I test for this better?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Oana · Jul 02, 2013 at 12:51 PM

The collider solution sounds quite good actually. It was just what I was going to suggest based on the title.

As for sticking to the original spline idea... well, do you need to compare it to just those determined points? Assuming you have a whole spline structure in place and you can just extrapolate any point, wouldn't it work to check what the closest point to the car is, and then moving the car towards a point that is a set distance along the spline? (Maybe increase this set distance based on speed)

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 noodlz · Jul 02, 2013 at 01:38 PM 0
Share

Yeah I'm in the process of trying the collider method now, if that proves to work well I may just stick with that. $$anonymous$$y main concern is if theres much of a performance hit using so many colliders?

If not your proposed alternative sounds like it would work, though definitely require a large amount of reworking in the code.

$$anonymous$$any thanks for your help!

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 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

Related Questions

Car- can someone help me convert this to C#? 1 Answer

Can not get value out of a collision 1 Answer

Steering an AI vehicle to a waypoint using float of -1 to 1? 1 Answer

Cars in City 1 Answer

How to make waypoints 8 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges