How do I make a mouse draggable lever? Like, I can actually use my mouse to drag it.
Or more generically, how do I allow mouse to drag objects while allowing them to spin and wobble as it’s being dragged by the mouse, as if it’s unanchored?
Detect if player clicked and use condition statement to see if it’s a part
If so then set Part Position to Mouse hit Position repeatedly until the player let’s go of mouse
You should get the point, there’s no specific property to do what you want, and no one is going to just code it for you. BUT you can ask for help when needed.
As for making a lever, I’m unsure but I’m sure if you ask around and do research you’ll find your answer eventually.
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.
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