Closed seanvail closed 8 years ago
The reason they fall right now is because I only interpolated the x/y location, letting the the physics engine control the Z-direction (gravity). We could interpolate the z location as well, but there is an issue with that. The pieces interpolate to the center of the square, but a pieces origin is the center of it's mesh. So, if we interpolated on the z-axis, the piece would come to rest with it's center at the center of the square, rather than it's bottom-center at the center of the square.
The way I was thinking about solving this is to have the code that centers the piece on a square check if the piece is currently below it's target. If so, it will move the piece towards that position. We would likely have to move to a location above the board for this to work.
Alternatively, interpolate on the z-axis, but target a position that is ((.5 * PieceHeight) + (.5 * SquareHeight)), above the square.
Went with the simple solution - if a piece is ever below the board (and not grabbed) it is just teleported above the board.
If the player hand moves the piece through the board mesh and releases, the piece falls through the board and to the floor.