check if point lie on a Polygon2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Help me please

Hi!
I only want to know how will I check if a given coordinate lies on a polygon2d or not

Do you need an intersection with its segment line?

sash-rc | 2021-08-15 14:29

No
Only I want to check if the point is on Polygon2D or not

Help me please | 2021-08-15 15:34

Are you there?

Help me please | 2021-08-18 05:58

:bust_in_silhouette: Reply From: Thomas Karcher

There’s a function for that in the GDScript Geometry class:

bool is_point_in_polygon ( Vector2 point, PoolVector2Array polygon )

Returns true if point is inside polygon or if it’s located exactly on polygon’s boundary, otherwise returns false.

https://docs.godotengine.org/de/stable/classes/class_geometry.html#class-geometry-method-is-point-in-polygon