GraphHitInfo.tangent is always same

I use GridGraph.Linecast method to check if the unit’s moved is hit obstacled grid, then I get the GraphHitInfo. I found whatever degree by moved, the hit.tangent always return (0,0,-1) ( unit is one the side right, obstacle is on the side left) ?

GraphHitInfo hit;
var obstruct = ( GoComponent.LogicPosition, nextPos, null,
                                                          out hit );

if ( obstruct )
    Vector2d hitp = hit.point;

    Vector2d vector = hit.tangent;
    int degree = (int) ( Math.Atan2 ( vector.y, vector.x ) * Mathf.Rad2Deg );
    CLog.Debug ( $"degress:{degree}" );  // always = -90
    speedVector = Singleton<GameInput>.Instance.GetDegreeVector ( degree );
    dist = speedVector * FixedMath.Create ( Speed ) * deltaSecond;
    nextPos = GoComponent.LogicPosition + dist;
    GoComponent.LogicPosition = nextPos;


Could you show a screenshot of this?

I’m not quite sure if you think the tangent is what it actually is. See the image in the documentation for a reference:

If start and end position is from left top to right bottom, is the tangent will change to opposite direction?


No, it will not change (or rather, the direction is unspecified). However you can use a simple dot product to check if it faces the ‘right’ direction for your use case.

Ok, I get it. Thanks very much!