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
2
Question by fifthknotch · Mar 08, 2014 at 05:30 AM · raycastcolliderainavmeshlaser

Why Do Raycasts Ignore NavMesh Agents

I built a simple game using Unity's built in NavMesh Ageant AI system. My player has a laser that uses a raycast to apply a force to the enemy to not it back. This works... for the first couple seconds of the game. Then, it is as if the NavMesh Agent gets "locked" into movement and is no longer effected by the raycast. I have found a few (very small number) other questions on UA, but none have answers that apply to my situation. Is this a bug in Unity? Or Am I missing some aspect of NavMesh Agents.

Comment
Add comment · Show 1
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 Meatloaf4 · Mar 11, 2014 at 08:08 AM 0
Share

I to am experiencing this issue and have yet to find a solution. It seems that my raycast collides for some arbitrary amount of seconds and then stops working. I'm currently using Physics.Raycast() but I have also tested with a sphere cast.

$$anonymous$$y code was set up as follows

Physics.Raycast(mainPosition, dirOne, out hitOne);

Please help!

4 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Meatloaf4 · Mar 11, 2014 at 08:37 AM

I believe I have a solution to the problem. I believe the problem occurs when you have both a navmesh agent on the object as well as a rigidbody. Remove the rigidbody and it should work fine.

Comment
Add comment · Show 2 · 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 fifthknotch · Mar 11, 2014 at 06:44 PM 0
Share

I will try this. I have a temporary fix right now. Triggers still work fine for nav$$anonymous$$esh agents so I have been just using triggers, but i will try your solution.

avatar image smallbit · Jul 13, 2015 at 06:31 PM 0
Share

$$anonymous$$eatlof you just saved me a lot of nerves and time :)

avatar image
3

Answer by Nubaa · Jan 10, 2019 at 03:32 AM

I realize this is years after the fact, but I was having this same problem. The only thing that was fixing it was what Meatlof4 said about removing the rigidbody, but then that made the navigation wonky. So what I did that seemed to fix it was I changed the Collision Detection on the rigidbody component from 'Discrete', to 'Continuous' instead. That seemed to fix it.

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 doug__ · Feb 15, 2015 at 01:58 PM

Try replacing the BoxCollider on your object with a MeshCollider.

This is probably due to mesh sort order; RaycastAll() will also work.

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 abhishekm942 · Jan 01, 2021 at 10:43 PM

Changing from discrete to continuous does not solve the issue. Rigidbody still needs to be removed.

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

24 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

Related Questions

Can't get a laser working properly. 2 Answers

Player's last location as a Transform 1 Answer

Why are raycasts so unreliable? 2 Answers

My Raycast dont hit. 3 Answers

Collider Vision AI question. Solved! 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