コード例 #1
0
    public void RequestMoveTo(
        Point3d point,
        float angle,
        PathComputer.OnPathComputedCallback onPathComputed)
    {
        // Set our new destination.
        // The position will update as we move along our path
        m_pathfindingComponent.SubmitPathRequest(
            point,
            MathConstants.GetUnitVectorForAngle(angle),
            (PathComputer pathResult) =>
        {
            if (pathResult == null)
            {
                // No result means we stopped in out tracks
                m_characterData.x     = Position.x;
                m_characterData.y     = Position.y;
                m_characterData.z     = Position.z;
                m_characterData.angle = angle;

                onPathComputed(PathComputer.eResult.success);
            }
            else
            {
                if (pathResult.ResultCode == PathComputer.eResult.success)
                {
                    // Set the character data immediately to the destination
                    m_characterData.x     = point.x;
                    m_characterData.y     = point.y;
                    m_characterData.z     = point.z;
                    m_characterData.angle = angle;
                }

                onPathComputed(pathResult.ResultCode);
            }
        });
    }
コード例 #2
0
 public void RequestMoveTo(Point3d point, float angle, PathComputer.OnPathComputedCallback onPathComputed)
 {
     SnapTo(point, angle);
     onPathComputed(PathComputer.eResult.success);
 }