Exemplo n.º 1
0
        public bool Raycast(Vector3 origin, Vector3 direction)
        {
            float      step    = CheckIncrement;
            Vector3Int lastPos = new Vector3Int();

            while (step < Reach)
            {
                Vector3 position    = origin + direction * step;
                var     newPosition = new Vector3Int(Mathf.FloorToInt(position.x), Mathf.FloorToInt(position.y), Mathf.FloorToInt(position.z));

                if (WorldModel.CheckVoxelOnGlobalXyz(position.x, position.y, position.z))
                {
                    HitPosition  = newPosition;
                    LastPosition = lastPos;

                    return(IsHit = true);
                }

                lastPos = newPosition;
                step   += CheckIncrement;
            }

            return(IsHit = false);
        }