Hi,
You can switch the cube’s body type between dynamic and kinematic when dragging. Kinematic means that user actions (or animation) are taken into account by the physics engine. So, if you make the cube kinematic at the start of the drag then by the end it will have its velocity vector set according to how the cube was being moved. But after that the cube should be switched to dynamic, so it will be fully controlled by the physics engine again.
Such puzzles setup can look like this:
But dragging by mouse can be inconvenient. It’s an instant movement, so the resulting velocity can be too large. The solution is to copy the current velocity vector, then set the cube’s velocity to zero and then apply a modified (normalized, scaled, etc…) velocity vector to the cube, so it will move in a more controlled manner:
Here’s the example: throw.zip
Attachments:
You must be
logged in to view attached files.
Co-founder and lead developer at Soft8Soft.