示例#1
0
    private void PlaceObjectOnWall(RaycastHit hit, KitchenObject o, float checkDist, LayerMask wallsMask)
    {
        if (hit.transform.tag != "Wall")
            return;

        Vector3 newPos = hit.point + o.transform.forward * o.HalfSize.z;
        if(o.TrySnap(ref newPos, checkDist, wallsMask))
        {
            o.transform.rotation = Quaternion.LookRotation(hit.normal);
            o.transform.position = newPos;
        }
    }
示例#2
0
    private void PlaceObjectOnGround(RaycastHit hit, KitchenObject o, float checkDist, LayerMask wallsMask)
    {
        Vector3 desiredPos;
        if (hit.transform.tag == "Wall")
        {
            o.transform.rotation = Quaternion.LookRotation(hit.normal);
            desiredPos = hit.point + hit.normal * o.Size.z;
            desiredPos.y = o.HalfSize.y;
        }
        else
        {
            desiredPos = hit.point + new Vector3(0, o.HalfSize.y, 0);
        }

        if(o.TrySnap(ref desiredPos, checkDist, wallsMask))
        {
            o.transform.position = desiredPos;
        }
    }