Skip to main content
Changing increment to match question.
Source Link
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

When in doubt, check the docs for the methods you're using.

Physics2D.Raycast takes an origin position and a direction, but you're passing it an origin and a destination

If you want to check 0.505 units up on the y axis, try...

float rayDistance = 0.05f;

Physics2D.Raycast(
    transform.position,
    Vector2.up,
    0.5frayDistance
);

When in doubt, check the docs for the methods you're using.

Physics2D.Raycast takes an origin position and a direction, but you're passing it an origin and a destination

If you want to check 0.5 units up on the y axis, try...

Physics2D.Raycast(
    transform.position,
    Vector2.up,
    0.5f
);

When in doubt, check the docs for the methods you're using.

Physics2D.Raycast takes an origin position and a direction, but you're passing it an origin and a destination

If you want to check 0.05 units up on the y axis, try...

float rayDistance = 0.05f;

Physics2D.Raycast(
    transform.position,
    Vector2.up,
    rayDistance
);
Source Link
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

When in doubt, check the docs for the methods you're using.

Physics2D.Raycast takes an origin position and a direction, but you're passing it an origin and a destination

If you want to check 0.5 units up on the y axis, try...

Physics2D.Raycast(
    transform.position,
    Vector2.up,
    0.5f
);