Ejemplo n.º 1
0
    IEnumerator MoveStuff(Direction direction)
    {
        Debug.Log("coroutine started");
        while (true)
        {
            Debug.Log("coroustine iteration");
            RaycastHit hit;
            if (Physics.Raycast(BevelInput.GetPrimaryControlRay(), out hit, 20f, planeLayer))
            {
                Vector3 deltaPosition = hit.point - previousLocation;

                if (direction == Direction.X || direction == Direction.XZ)
                {
                    //movementParent.transform.Translate(new Vector3(deltaPosition.x, 0, 0));
                    movementParent.transform.position = new Vector3(
                        hit.point.x - relativeHitPosition.x,
                        movementParent.transform.position.y,
                        movementParent.transform.position.z);
                }

                if (direction == Direction.Z || direction == Direction.XZ)
                {
                    //movementParent.transform.Translate(new Vector3(0,0,deltaPosition.z));
                    movementParent.transform.position = new Vector3(
                        movementParent.transform.position.x,
                        movementParent.transform.position.y,
                        hit.point.z - relativeHitPosition.z);
                }

                if (direction == Direction.Y)
                {
                    //movementParent.transform.Translate(new Vector3(0, deltaPosition.y, 0));
                    movementParent.transform.position = new Vector3(
                        movementParent.transform.position.x,
                        hit.point.y - relativeHitPosition.y,
                        movementParent.transform.position.z);
                }

                if (direction == Direction.Rotate)
                {
                    Vector3 previousAngleSource = previousRotationPoint - movementParent.transform.position;
                    Vector3 newAngleSource      = hit.point - movementParent.transform.position;
                    //float angle = Vector3.Angle(newAngleSource, previousAngleSource);
                    float angle = hit.point.x - previousLocation.x;

                    //movementParent.transform.eulerAngles = new Vector3(0,angle,0);
                    movementParent.transform.Rotate(this.transform.up, angle);

                    previousRotationPoint = hit.point;
                }
            }



            yield return(null);
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (!isPlaced)
     {
         RaycastHit hit;
         if (Physics.Raycast(BevelInput.GetCameraRay(), out hit, 10f, ARKitGroundLayer))
         {
             transform.position = hit.point;
         }
     }
 }
Ejemplo n.º 3
0
    public void StartMove(Direction direction)
    {
        Debug.Log("Starting Move");
        RaycastHit hit;

        if (Physics.Raycast(BevelInput.GetPrimaryControlRay(), out hit, 20f, planeLayer))
        {
            Debug.Log("Raycast has hit " + hit.point.ToString());
            relativeHitPosition   = hit.point - movementParent.transform.position;
            previousRotationPoint = hit.point;
            StartCoroutine(MoveStuff(direction));
        }
    }