How to get HitBlockCoords from FirstSolidHitTrace
#1
Salut,

I would like to use cLineBlockTracer.FirstSolidHitTrace to know what block the player is looking at. But the problem is that it returns only a boolean, which is true if there is a solid block, and false if not.




But in LineBlockTracer.h, it says :
/** Traces until the first solid block is hit (or until end, whichever comes first.
If a solid block was hit, returns true and fills a_HitCoords, a_HitBlockCoords and a_HitBlockFace.
If a_End is encountered without hitting any solid block, returns false and doesn't touch a_HitCoords, a_HitBlockCoords nor a_HitBlockFace.
a_HitCoords is the exact coords of the hit,
a_HitBlockCoords are the coords of the solid block that was hit,
a_HitBlockFace is the face of the solid block that was hit. */
static bool FirstSolidHitTrace(
  cWorld & a_World,
  const Vector3d & a_Start, const Vector3d & a_End,
  Vector3d & a_HitCoords,
  Vector3i & a_HitBlockCoords,
  eBlockFace & a_HitBlockFace
);

So I tried :
cLineBlockTracer.FirstSolidHitTrace(World, Start, End, a_HitCoords, a_HitBlockCoords, a_HitBlockFace);

which gives in the console :
Code:
error in function ’FirstSolidHitTrace’: Too many arguments.
argument #4 is ’nil’; ’[no object]’ expected.

I also tried other ways to get it, like just to refer to a_HitBlocksCoords further in the code, but I got nothing.

Could someone explain me how I can get these parameters, please ? Thanks ^^

Here is the full function :
function WhatISee(a_split, a_Player)
local World = a_Player:GetWorld();

local EyePos = a_Player:GetEyePosition();
local LookVector = a_Player:GetLookVector();
LookVector:Normalize();  -- Make the vector 1 m long

local Start = EyePos;
local End = EyePos + LookVector * 50;

cLineBlockTracer.FirstSolidHitTrace(World, Start, End, a_HitCoords, a_HitBlockCoords, a_HitBlockFace);

return true;
end


Beuj

(edited by xoft to use shcode tags)
Reply
Thanks given by:


Messages In This Thread
How to get HitBlockCoords from FirstSolidHitTrace - by Beuj - 09-01-2019, 05:56 AM



Users browsing this thread: 1 Guest(s)