Giter VIP home page Giter VIP logo

navmeshavoidance's Introduction

Nav Mesh Avoidance

Custom Nav Mesh Avoidance to replace default one.

Nav Mesh Avoidance

This is simple avoidance implementation to prevent situation when nav mesh agents moving too close to each other. This algorithm is best suitable for average crowds of 10-100 agents. Not tested with bigger amounts.

You can combine this Avoidance with default one (agents will never move through each other) or disable Unity's avoidance (avoidance will look smoother, but agents will be able to move through each other).

How to install

You can install plugin via Unity Package Manager as git package from github repository:

https://github.com/OlegDzhuraev/NavMeshAvoidance.git

You also can download it directly from github and place into Assets folder.

How to use

First of all, add Avoidance component to any GameObject (once). Next, when you spawn any agent, you need to add it to the Avoidance class like this:

using NavMeshAvoidance;
using UnityEngine;
using UnityEngine.AI;

public class AvoidingAgent : MonoBehaviour
{
  [SerializeField] Avoidance Avoidance;

  void Start()
  {
    var agent = GetComponent<NavMeshAgent>();

    Avoidance.AddAgent(agent);
  }
}

And now it will work with avoidance of others agents.

You also can disable default avoidance. In this case agents will sometimes move through each other, but in priority for them will be to avoid others. Idea of disabling default avoidance is better navigation without "friction", which can be noticed when using default avoidance and 2 or more agents try to move through other one.

When destroying any agent, dont forget to remove it from avoidance too:

Avoidance.RemoveAgent(agent);

Ordering and Formation

Basic classes added as controls example for agents groups. You can ignore these scripts if you have your own group controls.

Example

Check SampleScene to see Avoidance work example.

navmeshavoidance's People

Contributors

olegdzhuraev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.