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 SGPascoe · May 03, 2012 at 10:58 AM · colliderainavmeshagentnavigationnav mesh

How do I stop an Enemy NavMeshAgent from intersecting the player model?

When I have the player walking and the enemy model static, they collide with each other as expected.

When I make the enemy a Nav Mesh Agent, they stop colliding. If I use Ctrl+D to create multiple Nav Mesh Agent enemies , they collide with each other, but still not with the player model.

Why will they no longer collide with my player model, and how can I get them to? As a top-down shooter, it's quite important. (The player is using the 'character controller' and collides with every other object.)

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

3 Replies

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

Answer by asafsitner · May 03, 2012 at 12:56 PM

Just add a NavMeshAgent component to the player as well. The enemies, being NavMeshAgents are driven around using an entirely different system than physics or CharacterControllers, instead being driven by CrowdManager (see the profiler). They're only aware of other entities that are driven by the CrowdManager, and only if their avoidance property is set to something other than None (obviously the better the avoidance quality the more resources are required).

Adding a NavMeshAgent component to the player - even if you keep moving it around with the CharacterController! - will allow the other NavMeshAgents to perceive it and avoid collision with it.

A nice side-effect of this is that your player will be able to push enemies aside as it's colliding with them, which could be useful to, say, throw enemies off cliffs and to oblivion.

Comment
Add comment · Show 3 · 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 SGPascoe · May 03, 2012 at 01:49 PM 0
Share

This answer and explanation is perfect! Thanks very much!

"A nice side-effect of this is that your player will be able to push enemies aside as it's colliding with them, which could be useful to, say, throw enemies off cliffs and to oblivion."

This is the effect I was hoping for also!

I did try to add the Nav$$anonymous$$eshAgent to the player but it effected the movement, and I wasn't sure it was the best approach. Now I know it's the correct thing to do, I'll try to get it working.

Thanks again! This is a great help!

avatar image LukaKotar · May 11, 2012 at 04:18 PM 2
Share

I don't get it. If I attach the Nav$$anonymous$$eshAgent to my character, it won't allow me to rotate the camera, as it always goes back to the original position. I'm confused.

avatar image TutiBueno2 · Nov 21, 2012 at 01:49 PM 0
Share

Another useful alternative is to check on script the distance from enemy to character and just stop the agent. Curiously the only way to do this is to use a new path which is the position of the enemy since agent.Stop() is not working for me.

avatar image
2

Answer by bubbabruce · Apr 28, 2017 at 06:00 AM

I attach a NavMeshObstacle to the player and that seems to work.

NavMeshObstacle documentation

Use it with carving unchecked. It mentions using this for player characters: "This mode is best used in cases where the obstacle is constantly moving (for example, a vehicle or player character)"

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 MonkeyPuzzle · Aug 08, 2018 at 04:31 AM 0
Share

This solution worked for me. Thanks.

avatar image
0

Answer by barmhartsam · Mar 03, 2017 at 06:19 PM

@asafsitner I know this is old but I have queries/ Setting the Navmesh on my player that is driven by Characther Controller messes with the ground check of my Charachter controller. Also the Friendly NPC walks underneath my player while pathfinding. If no Navmesh is attached to playe it walks throuh player. Any advice.

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Navmesh Agent "move back" when player comes to close? 1 Answer

Way to find closest point in a specific area on navmesh. 0 Answers

Having trouble with enemy AI and Collider 0 Answers

2 NavMeshAgent 0 Answers

CS0246: The type or name space name ''NavMeshSurface'' plz some help 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