drwhut / tabletop-club

An open-source platform for playing tabletop games in a physics-based 3D environment for Windows, macOS, and Linux! Made with the Godot Engine.
https://tabletopclub.net
MIT License
1.27k stars 55 forks source link

Piece flies out #166

Closed GrimPixel closed 1 year ago

GrimPixel commented 1 year ago

Describe the bug Piece flies out

To Reproduce Left-clicking on a piece and hold for a moment, it will be accelerated and if stopped holding during the acceleration, the piece will fly out of the scene.

Additional context Maybe highlighting the piece instead of moving it upwards is better.

elmodor commented 1 year ago

140 fixed that the piece is only going up when hovering, so it should not fly off the table anymore.

I think it's fine that the hover moves the piece a bit up, because if it doesn't you would need to move it up manually all the time when you want to move something - and that's why you hold the piece anyways: to move it.

But the acceleration needs to be fixed. So whenever stop_hovering is called we need to make sure that we don't keep the current linear_velocity - since we stop the hover and the hover_position is not used anymore but the linear_velocity seems to be kept. But this should not affect "throwing" objects - so how do we know if the object is being thrown or just trying to get to its hovering position?

GrimPixel commented 1 year ago

Yes, lifting it a bit looks good. The improvement could be specifying the lift and drop distance, to make sure the piece doesn't collide with other pieces and doesn't fall after dropping. If the velocity is horizontal, then it's throwing.

elmodor commented 1 year ago

Yeah it was a bit late yesterday. Resetting the linear_velocity in Y should suffice.