Esempio n. 1
0
 public void Initialize(NavAgent agent)
 {
     this.mAgent = agent;
     mCrowdDebug = null;
     mCorners    = null;
     mCorridor   = null;
 }
Esempio n. 2
0
    void OnRenderObject()
    {
        if (!mDebugEnabled || mAgent == null)
        {
            return;
        }

        if (mAgent.crowdAgent != null)
        {
            if (mCrowdDebug == null)
            {
                mCorners    = null;
                mCorridor   = null;
                mCrowdDebug = new CrowdAgentDebug(mAgent.navGroup.crowd.Navmesh);
            }
            mCrowdDebug.DrawAll(mAgent.crowdAgent);
        }
        else if ((mAgent.data.flags & NavFlag.CorridorInUse) != 0)
        {
            if (mCorridor == null)
            {
                mCorners    = new CornerData();
                mCorridor   = new PathCorridorData(mAgent.corridor.MaxPathSize);
                mCrowdDebug = null;
            }
            int n = mAgent.corridor.FindCorners(mCorners);
            mCorners.cornerCount = n; // v0.3.0 bug workaround.
            mAgent.corridor.GetData(mCorridor);
            NavDebug.Draw(mAgent.navGroup.mesh, mCorridor);
            NavDebug.Draw(mCorners);
        }

        if (mAgent.crowdAgent == null)
        {
            Vector3 pos    = mAgent.data.position.point;
            float   height = mAgent.crowdConfig.height; // Might be zero.

            Vector3 velocity = mAgent.data.desiredVelocity;
            DebugDraw.Arrow(pos + Vector3.up * height
                            , pos + velocity + Vector3.up * height
                            , 0, 0.05f, CrowdAgentDebug.desiredVelocityColor);
        }

        DebugDraw.DiamondMarker(mAgent.data.position.point
                                , 0.1f
                                , NavDebug.positionColor);

        DebugDraw.DiamondMarker(mAgent.data.goal.point
                                , 0.1f
                                , NavDebug.goalColor);
    }