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 /
avatar image
0
Question by FedaYkinG · Mar 12, 2018 at 01:06 PM · aicar physicscar race

Pursuit Car AI that follows target on the track

Hello. I have an issue with a pursuit AI system. So I have a police car (AI controlled) that should follow the player while the player is racing in a circuit-like track. I am using the standard asset Car AI for the police, with the target being the transform of the player car. The circuit is built as a terrain with a drivable course on it. alt text

I described my issue with an image. So the blue dots represent the police units, and the green and orange dots racer cars in 2 possible scenarios when it comes to position relative to the pursuing cop car. For the orange racer, the standard asset Car AI does a good job since the cop follows the orange car in a straight line, however for the 2nd scenario (green racer), if the cop car is behind a turn, it will try to go straight to the racer and crash/get out of the track.

Can someone tell me some way to modify the standard Asset car AI (preferably) to allow it to stay on track while pursuing a racer? From what i've seen, pathfinding should be a thing, but i couldn't find any good asset for it that can handle vehicle steering nor any tutorials about achieving this, and implementing my own pathfinding system that can handle this car ai controller seems quite huge.

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 Honorsoft · Mar 17, 2018 at 10:58 PM

There is at least two ways to accomplish this, either use a waypoint system (where there are waypoints in the middle of the road and placed every so often along your whole track/path) and your AI car will always attempt to follow those. Unfortunately, Unity's AI waypoint system needs to be gutted and rewritten due to flaws, so it will likely still be hard to get the Standard Assets AI Car Controller to stay on the road. But there is already a built-in waypoint system/method already in StandardAssets.

The second way is to use a 'target-follow' script to follow the target car, and a raycast coming from it to detect whether there is an obstacle (track border or debris on racetrack, etc.) in the way. If the path to the target car is not clear, it can keep adding steering or horizontal movement until it has cleared the obstacle, then continue with the plain target following. In your case, the car would steer LEFT to avoid the 'track wall'. You could also look into the NavMesh stuff in Unity, since it contains pathfinding that avoids obstacles already, you just have to set the track area as the only 'allowed' area for AI to travel on. There workarounds too, like a 2nd target position for the AI to follow that helps adjust a proper course.

In a racetrack scenario, you don't really need a direct 'follow the target' setup, because in a race all you have to consider is whether the AI has caught up to the player or not. The AI shouldn't cut across the track to catch the player, he always follows the track. So you could just have the AI drive until he is really close to the player, and that's when the code for 'interaction' happens, so that the AI won't try to cut corners chasing them. Basically, the AI ignores the player until really close. Also, you could avoid using waypoints all-together, and just have a script that adjusts the steering of the AI car to keep in the middle of the road/track (constantly checking the 'walls'). I hope some of this helps, I just started looking into using the StandardAssets car-controller instead of using my own, so I will probably run into the same problems. I already noticed issues with needless swerving to follow waypoints.

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

127 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 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 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

Cannot make initial speed for the Player car using AIDriverToolkit 0 Answers

How add kilometre per hour system in car script,how to add kilometre per hour speed system in script 0 Answers

drift car using rigidbody 1 Answer

how to rotate car to camera direction using wheel colliders. 1 Answer

A game like Need For Speed? 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