Quantcast
Channel: Questions in topic: "mass"
Viewing all articles
Browse latest Browse all 157

Movement with NavMeshAgent pushes RigidBody

$
0
0
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!

Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>