I can make a physical object impulse towards mouse.x/y, but how do I compare mouse x/y and then apply variable impulse away from the mouse location on click?
example: the closer the mouse is to the object, the higher the impulse (limited to 10 maybe) and the farther away the less impulse (limited to 1 maybe)
Thank you!
Develop games in your browser. Powerful, performant & highly capable.
Use angle(mouse.x, mouse.y, object.x, object.y) and distance(mouse.x, mouse.y, object.x, object.y) expressions.
For example, you can try something like this:
Apply impulse clamp(200/distance(mouse.x, mouse.y, object.x, object.y), 1, 10)