- Home /
Question by
mamuelSraz · Oct 04, 2020 at 08:32 PM ·
physics2dphysics2d.raycast
raycast2d.point returns bad position
the blue point is where the raycast2d.point is, however it should be at the start of the platform.
here is the code that returns the blue point:
Vector2 compute_ideal_position(Vector2 origin) { RaycastHit2D best_ray = new RaycastHit2D(); foreach (RaycastHit2D ray in Physics2D.CircleCastAll(origin, 10f, Vector2.one, 0f, ~IgnoreMe)) { if (best_ray.collider == null) best_ray = ray; if (ray.distance < best_ray.distance) best_ray = ray; Debug.DrawLine(origin, ray.point); } return best_ray.point; }
why isn't it returning the position that i want?
unknown.png
(40.8 kB)
Comment