diff options
Diffstat (limited to 'src/GameState.cpp')
-rw-r--r-- | src/GameState.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp index 650cd6f..180db98 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -36,7 +36,9 @@ void GameState::Update(float deltaTime) { direction.y = sin(glm::radians(playerPitch)); direction.z = sin(glm::radians(playerYaw)) * cos(glm::radians(playerPitch)); - selectedBlock = world.Raycast(player->pos + player->EyeOffset, direction, distanceToSelectedBlock); + RaycastResult raycast = world.Raycast(player->pos + player->EyeOffset, direction); + selectedBlock = raycast.isHit ? raycast.hitBlock : Vector(0,0,0); + distanceToSelectedBlock = raycast.isHit ? (player->pos - raycast.hitPos).GetLength() : 0.0f; } } |