Hi,
I’m having an issue with 2d raycasting. I have a player object(blue rectangles) that moves around a polygon(blue polygon). When I run a physics2d.raycast(green lines) from the player to the center(trasform.position) of the target polygon, it returns a hit, but ONLY on the left side of that polygon. If I move to the right, it ceases to return a hit and the hit.point position sticks to the top-most or bottom-most vertex of the polygon collider.
Does anyone know why such an error occurs?
Here is my raycasting:
//raycast from rectangle to selected shape/body
RaycastHit2D hit
= Physics2D.Raycast(transform.position,
polygon.transform.position,
Mathf.Infinity,
1 << LayerMask.NameToLayer("Ground"));
Thanks for any suggestions.