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 RLin · Jun 13, 2015 at 01:01 AM · collidertriggeraicollidersartificial intelligence

Trigger-based vehicle ai?

Is it feasible to create an AI system using triggers to detect objects? If not, why? If yes, would there be any major drawbacks?

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
1
Best Answer

Answer by eeveelution8 · Jun 13, 2015 at 06:18 AM

It largely depends on what kind of game you are making, if were a vehicle combat game kind of like Twisted metal where the cars would insted become hostile after triggering them, a good way to start would be having large trigger colliders placed where you want the car to become hostile. Have all the coding for the car done, but have it only activate when a condition (for example a boolean) is met. Once it has, the cars AI will activate and try to get you. The trigger boxes can be set to make the cars condition met once entered, then delete themself.

If it on the othe hand is a scripted AI that appears when the player enters a street for example, the same kind of trigger box can utilise the SetActive(true); command, while having the cars AI premade to activate on the Start function, initially set to be inactive.

If it's a racing game, I don't see how triggers will come into play.

Comment
Add comment · Show 5 · 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 RLin · Jun 13, 2015 at 01:14 PM 0
Share

Actually, a racing game is exactly what I'm making. I'm thinking of using triggers attached to the ai cars so they know when to brake (ie a traffic car enters the trigger, so they slow down), and also steer. Also, police cars might use trigger so they know that they are in range of a suspect to stop an arrest them.

avatar image eeveelution8 · Jun 13, 2015 at 04:58 PM 0
Share

If you are doing a racing game, try having all the behaviours your cars can do pre-coded, but activated when they enter specific triggers setup at traffic lights, crosswalks, etc.. Just make sure to add sections in your code that make the AI know to tart moving again after having been triggered to slow down, and speed up.

As for cop cars, You may want to try having them have a large hit box trigger within them, and when the player enters the space, the cops go hostile and chase you.

avatar image RLin · Jun 13, 2015 at 05:02 PM 0
Share

Actually, what I meant was triggers for the actual cop chasing part, (ie if player is in trigger one, drive left, if he/she is in trigger two, drive right), but the other uses do sound like they could work well.

avatar image eeveelution8 · Jun 13, 2015 at 06:32 PM 0
Share

for that, it may be a little harder, if you want to make it organic and sandboxy, I don't know how to help you, but if it's linear, and the roads are preset, having the trigger be set to tell the cop to turn to keep going would work. but this requires there to be a set number of paths to make.

If you are going the sandbox route where the areas you can drive are anywhere, try looking to navmeshes and nav agents, since that amount of fiddlyness with triggers would be a worse use of your time than to learn navmeshes.

avatar image RLin · Jun 13, 2015 at 07:24 PM 0
Share

Unfortunately, I can't use a navmesh or navagent because the cars are controlled by wheelcolliders. You did answer my question, though, so thanks.

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

23 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

Related Questions

Use different colliders 3 Answers

Can't click gameobject when over another trigger? 1 Answer

How to Specify a Collider in OnTriggerStay function? 1 Answer

Multiple OnTriggerEnter in one script 1 Answer

changing gravity OnTriggerEnter 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