Beispiel #1
0
    private void CreateTravelerClone(PortalTraveler portalTraveler, bool enteredFromBack)
    {
        lstPortalTravelers.Add(portalTraveler);
        TransformToTarget(portalTraveler.transform, out Vector3 newPos, out Quaternion newRot);
        PortalTraveler travelerCopy = Instantiate(portalTraveler, newPos, newRot);

        travelerCopy.enabled = false;

        SimpleMove simpleMoveComponent = travelerCopy.GetComponent <SimpleMove>();

        if (simpleMoveComponent)
        {
            simpleMoveComponent.enabled = false;
        }

        Sliceable sliceable = portalTraveler.GetComponent <Sliceable>();

        sliceable.SlicePosition = transform.position;
        sliceable.SliceNormal   = transform.forward;
        sliceable.IsSliceable   = true;
        sliceable.Flip          = !enteredFromBack;
        sliceable.UpdateMaterialSlice();

        if (target)
        {
            sliceable = travelerCopy.GetComponent <Sliceable>();
            sliceable.SlicePosition = target.transform.position;
            sliceable.SliceNormal   = target.transform.forward;
            sliceable.IsSliceable   = true;
            sliceable.Flip          = enteredFromBack;
            sliceable.UpdateMaterialSlice();
        }

        travelerCopies.Add(portalTraveler, travelerCopy.gameObject);
    }
Beispiel #2
0
    public void OnTriggerExit(Collider other)
    {
        PortalTraveler portalTraveler = other.GetComponent <PortalTraveler>();

        if (portalTraveler != null)
        {
            if (other.CompareTag("Player"))
            {
                playerTraveler = null;
                var originalPosition = new Vector3(0, portalDisplay.transform.localPosition.y, 0);

                PortalAdjustment(originalPosition, originalPortalScale);
                target.PortalAdjustment(originalPosition, originalPortalScale);
            }
            else
            {
                Sliceable sliceable = portalTraveler.GetComponent <Sliceable>();
                sliceable.IsSliceable = false;
                sliceable.UpdateMaterialSlice();
                TransformToTarget(portalTraveler.transform);
                lstPortalTravelers.Remove(portalTraveler);
                DestroyTravelerCopy(portalTraveler);
                travelerCopies.Remove(portalTraveler);
            }
        }
    }