Object distance to collider2d object, no idea

Hello, this is my first post. I am creating my own game and i have no idea how to measure distance from object (which can be dragged by mouse) to another object (which is BoxCollider2D, used for ground(not falling down).
Better look on screen below:

I think it can be done by raycast but i am not sure and i don’t know how. Docs needs examples!

Here is some good reference for you. I hope it helps you achieve your expectation. Peace.

@hahaha2ne1 helpful, but i have sprite so line is not good idea. This brings me idea,
make two variables, one on mouseUp second on mouseDrag. Is it good?

edit: I did it, works fine. Thanks

1 Like