Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Raycast every tick and keep track of the current block the camera is …
Browse files Browse the repository at this point in the history
…looking at
  • Loading branch information
Oliver-makes-code committed Dec 4, 2023
1 parent 4685a0c commit bc61246
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Client/VoxelClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public class VoxelClient : Game {

public ClientWorld? world { get; private set; }

public double timeSinceLastTick = 0;
public double timeSinceLastTick;

public Raycast.HitResult? blockLooking;

public VoxelClient() {

Check warning on line 24 in Client/VoxelClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'GameRenderer' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
Instance = this;
Expand Down Expand Up @@ -98,6 +100,8 @@ public override void OnTick() {
camera.MoveAndSlide(world!, inputDir);

GameRenderer.WorldRenderer.ChunkRenderer.SetRenderPosition(camera.position);

blockLooking = world.Cast(camera.position, camera.position + camera.rotation * new vec3(0, 0, -5));

Check warning on line 104 in Client/VoxelClient.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'world' in 'HitResult? Raycast.Cast(BlockView world, dvec3 rayOrigin, dvec3 rayDest)'.
}

public override void OnWindowResize() {
Expand Down

0 comments on commit bc61246

Please sign in to comment.