示例#1
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        Vector3    slicingDirection = endSlicingPoint.position - startSlicingPoint.position;
        bool       hasHit           = Physics.Raycast(startSlicingPoint.position, slicingDirection, out hit, slicingDirection.magnitude + 0.5f, sliceableLayer);

        if (hasHit)
        {
            BrokenOre ore = hit.transform.gameObject.GetComponent <BrokenOre>();
            if (ore.possible)
            {
                Slice(hit.transform.gameObject, hit.point, velocityEstimator.GetVelocityEstimate(), ore);
            }
        }
    }
示例#2
0
    void Slice(GameObject target, Vector3 planePosition, Vector3 slicerVelocity, BrokenOre ore)
    {
        Debug.Log("WE SLICE THE OBJECT");
        Vector3 slicingDirection = endSlicingPoint.position - startSlicingPoint.position;
        Vector3 planeNormal      = Vector3.Cross(slicerVelocity, slicingDirection);

        SlicedHull hull = target.Slice(planePosition, planeNormal, slicedMaterial);

        print(hull);
        if (hull != null)
        {
            ore.BrokenObject();
            GameObject upperHull = hull.CreateUpperHull(target, slicedMaterial);
            GameObject lowerHull = hull.CreateLowerHull(target, slicedMaterial);

            CreateSlicedComponent(upperHull);
            CreateSlicedComponent(lowerHull);

            Destroy(target);
        }
    }