예제 #1
0
    public HitInfo GetHit()
    {
        HitInfo info = new HitInfo();

        info.hit = false;

        Ray     ray   = Camera.main.ScreenPointToRay(Input.mousePosition);
        Vector3?point = Utils.Raycast(ray, editRange);

        if (point.HasValue)
        {
            info.hit = true;
            Vector3  pos    = point.Value;
            Vector3i hitPos = Utils.GetBlockPos(pos + ray.direction * 0.01f);
            info.hitPos = hitPos;

            pos        -= ray.direction * 0.01f;
            info.adjPos = Utils.GetBlockPos(pos);

            info.CalculateNormal();
        }

        return(info);
    }