User Tools

Site Tools


tutorial:pixel_raycast

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:pixel_raycast [2020/08/26 08:22] – [General case: Arbitrary pixel] Updated to use RayCast instead of RayTrace snakefangoxtutorial:pixel_raycast [2023/11/30 22:33] (current) – [For arbitrary reach] Naming fix famrofexl
Line 34: Line 34:
 ==== For arbitrary reach ==== ==== For arbitrary reach ====
  
-The code above allows for the normal reach, 3 blocks for survival and 4.5 in creative. If you want the raycast to reach farther you need to use the general case below.+The code above allows for the normal reach, 3 blocks for survival and 4.5 in creative. If you want the raycast to reach farther you need to replace <code java> HitResult hit = client.crosshairTarget;</code> in [[pixel_raycast#special_casecenter_pixel | Special Case: Center Pixel]] with the example below
 + 
 +<code java [enable_line_numbers="true"]> 
 +double maxReach = 1000; //The farthest target the cameraEntity can detect 
 +float tickDelta = 1.0F; //Used for tracking animation progress; no tracking is 1.0F 
 +boolean includeFluids = true; //Whether to detect fluids as blocks 
 + 
 +HitResult hit = client.cameraEntity.raycast(maxReach, tickDelta, includeFluids); 
 +</code>
  
 ===== General case: Arbitrary pixel  ===== ===== General case: Arbitrary pixel  =====
Line 191: Line 199:
 ==== Performance considerations ==== ==== Performance considerations ====
  
-This is EXPENSIVE, if you do it too many times, it WILL get slow. Especially for long reaches. If you *need* to do many raycasts in a single frame, [[https://stackoverflow.com/q/777997/3124150|this]] link might be helpful.+This is EXPENSIVE, if you do it too many times, it WILL get slow. Especially for long reaches. If you **need** to do many raycasts in a single frame, [[https://stackoverflow.com/q/777997/3124150|this]] link might be helpful.
tutorial/pixel_raycast.txt · Last modified: 2023/11/30 22:33 by famrofexl