Search Unity

Navmeshes alongside physics, colliders, and rigidbodies?

Discussion in 'Scripting' started by Nanako, Mar 4, 2015.

  1. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    I have a UA thread up on the topic, but i'm not really getting enough opinions. There are some pictures there too: http://answers.unity3d.com/question...finding-get-screwed-up-aft.html#answer-912995

    The issue roughly, is that i have a little creature with a capsule collider, a rigidbody, and a navmesh agent. I'm using navigation to make it move towards where the player clicks, attempting to steer around obstacles and such as it goes

    The problem is that right now, when the creature hits a wall, bad things often happen. And they seem Far MORE likely if the creature hits a moving rigidbody, which it is definitely going to do at some point.

    The greature bounces around, kind of spazzes out, and becoems unable to pathfind properly until i stop and restart play mode. It will either move at extremely slow/inconsistent speeds to the target, get stuck inside a wall, run in place as if against an invisible wall, or (most often) it will reach the target but be unable to stop and settle, instead fidgeting around ontop of it endlessly. (yes a generous stopping distance is set for the navmeshagent)

    All of these problems seem to be avoided if i disable the collider on the creature, but that's not an acceptable solution. That causes projectiles and obstacles to pass right through it (or vice versa and i need such functionality for my game.

    I'd like suggestions on how to fix this, and/or examples of how it's been fixed before.

    I'm particularly interested in the idea of replacing the navmesh agent class entirely, with a version that uses PhysX and moves the creature around with forces. But i'm not relishing the work in coding, testing and polishing such a thing, and i'm hoping that someone else has already done it. Is such a thing available as a library floating aorund, or even as an object on the unity asset store?

    Alternatively, are there any other soluitions that could work here? relative sizes of the agent and collider? rigidbody settings? using a trigger collider?

    give me some advice please
     
  2. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    bump!

    if i am destined to write a physical navmesh cvontroller, i would appreciate help with a few issues Like the auto braking fucntion, how does that work? is there a good formula for it? how close to the target doi start decreasing the force

    and what about step height? How can i make a rigidbody climb stairs
     
  3. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    gosh the scripting forum is high traffic, should i go and post this in physics insead
     
  4. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    you'll have to write your own movement code.

    use the agent to calculate a path, set updatePosition, updateRotation to false, use the path how you so desire.
     
  5. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    i see. Do you have much experience with this?

    moving between points will be easy enough, but i've no idea how i'll do things like wide turning, or braking when getting near the target. i would appreciate any code snippets or advice you might have to throw at me x