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
1
Question by blachance · Sep 09, 2013 at 07:07 PM · movementrigidbodynavmeshnavmeshagentmass

Movement with NavMeshAgent pushes RigidBody

Hi all. I've started using the navmeshagent and have come across something I can't seem to fix. It seems that if an object is moving using the navmeshagent, it will push rigidbodies regardless of their mass/drag. I'm hoping someone here might know how to fix or work around this.

Here is my setup:

  • Enemy is a RigidBody (isKinematic = true), NavMeshAgent, and CharacterContoller (for collisions only), custom AI script

  • I've also tried the above Enemy with: Kinematic Rigidbody, NavMeshAgent, and Capsule Collider (no CharacterController), custom AI Script

  • Cube is a Box Collider and Rigidbody.

No matter what mass I set the Cube rigidbody to (0.1 to 10), the Enemy will push it away as if the mass doesn't matter. I use the navmeshagent SetDestination() for enemy movement, but navmeshagent.destination has the same issue. I've determined that navmeshagent is my best choice for movement for what need in other aspects of the game.

My objective is to allow the Enemy to be able to push aside Rigidbodies if its "strength" is great enough. Otherwise it just runs into the object (and tries to push it but fails) and stops moving forward (although it could keep trying). This means that the Nav Mesh Obstacle component won't meet my needs. In the game flow, these obstacles can appear, be moved by the player, and be destroyed - so I can't set them as static or bake them into the navmesh.

I've already added to the Enemy AI script a detection of the cube with OnCollisionEnter which applies AddForce (Impulse) to the cube to push is aside. This works fine when the "strength" is large enough to overcome the cube mass. However, if the cube is too heavy, the "push" script still applies the too-weak force and cannot move the cube, but the Enemy still pushes the cube as if the mass doesn't matter.

I'd really like to avoid having to turn off the navmeshagent on a rigidbody collision, reference the next nav corner, switch to some other method of movement that works with physics, try to push the object, detect when the object is no longer in the way, and switch back to navmeshagent (assuming this would even work). So, I'm hoping I'm just missing something in my setup that is causing this problem.

Help or advice would be greatly appreciated!

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

Answer by blachance · Sep 10, 2013 at 03:57 PM

I figured it out, and luckily it was just a problem with my setup. This works:

  • Cube: Box Collider and Rigidbody.

  • Enemy: NavMeshAgent, Capsule Collider (non-trigger), Rigidbody (NON-kinematic) with Constraints Freeze Rotation x,y,z.

I had tried this combination before but got strange behavior and gave up on it, all because I forgot to freeze the rotation!

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 blachance · Sep 10, 2013 at 10:29 PM 0
Share

Well, the good news is: the above works as it's supposed to. The bad news is: Enemies can't walk up stairs. Oh well, I might have to rethink the basics of how I want the game to work.

avatar image FuzzyQuills · Nov 28, 2014 at 01:14 AM 0
Share

In case anyone wonders about the above stairs problem, I would try setting the rigidbody to kinematic, or disabling gravity when the character encounters stairs. using a trigger at the top and bottom of such stairs would help with this.

Since I haven't fiddled around with the Nav$$anonymous$$esh stuff much, go ahead and try this, but take my reply as a grain of salt otherwise! ;)

avatar image StasPisarev · Oct 29, 2015 at 01:51 PM 0
Share

I have this problem to, and fix when change Base Offset.

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

17 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

Related Questions

A little help with using Navmesh agents with RigidBody physics. 0 Answers

New Way to stop navmesh Agent 2 Answers

Navmesh problem with characters rotation in the terrain 1 Answer

What’s the simplest way to find nearest navmesh targets? 0 Answers

Changing only vertical speed on NavMeshAgent? 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