The key here would be getting the mouse delta (which means how much the mouse since the last processed frame) and translating its direction to something usable in the game world (since mouse coordinates are in 2D space) to determine the movement that will be applied to the object.
Determining mouse delta will be useful here, because for example if the user is moving their mouse quickly, you’ll want to apply more power or force to the object.
Reference to that here: UserInputService:GetMouseDelta
How my problem analysis for this would probably look like:
-
Detect mouse down input, determine if the user is hovering over an interactable object.
-
While mouse is down, and if interactable object was found, apply force to the object according to mouse movement. Get mouse delta, then determine the direction of force to apply to the object.
-
When mouse button is released, stop applying any force to previous interaction object