How to drag dynamic collision objects with cursor in a realistic way?

Object should be able to interact with other physics objects while being dragged, like not passing through static collision objects or overlapping with other dynamic collision objects.
Forced should be applied from the spot of first click and modify the angular and linear velocity accordingly until release.
When released should loose velocity overtime with dampening.

How to achieve the described drag movement? :thinking:

extra info: ortographic top down view, gravity z axis faked with dampening.

What have you tried? Have you tried moving a dynamic physics object using code?

Here’s a quick example (box moves with mouse, no click to drag and release):

collisiondrag.zip (2.8 KB)

One improvement would be to do ray casts to detect rapid mouse movement.

2 Likes