raycast2d returns true only from one way ...

hey there,
i’m playing around with raytrace in defualt 2d workspace, and for the most part everything i do with raycast works perfectly
BUT !
there is a certain case where things get weird :frowning:
it only works one way, like this screenshot shows, the raycast ‘collides’ with block tile normally…

40532-case1.jpg

but if the origin and target are reversed, for some reason raycast won’t detect the blocking tile
and I’m loosing my mind and precious sleep :slight_smile: … any ideas what I’ve missed ?

40533-case2.jpg

            Vector2 currentLoc2d = new Vector2(currentCharacter.transform.localPosition.x, currentCharacter.transform.localPosition.y);
            Vector2 targetLoc2d = new Vector2(currentCharacter.ai_target.x, currentCharacter.ai_target.y);
            float distanceToTrace = Vector2.Distance(currentLoc2d, targetLoc2d);

            RaycastHit2D hit = Physics2D.Raycast(currentLoc2d, targetLoc2d, distanceToTrace, 1 << 9);
            if (hit != null)
            {
                if (hit.transform != null )
                {
                    Debug.LogWarning(hit.transform.tag);
                }

Direction argument in the Physics2d.Raycast function should not be the target, but (target-origin).normalized :). That’s probably it.