Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     Ray = new Ray(transform.position, transform.forward * 5f);
     if (Physics.Raycast(Ray, out Hit))
     {
         Debug.Log("hitting it " + Hit.collider.name);
         isHitting = true;
         var tmpKnot = Hit.transform.GetComponent <MovementKnot>();
         if (tmpKnot != null)
         {
             lastKnot             = tmpKnot;
             lastKnot.isPointedAt = true;
         }
         else
         {
             if (lastKnot)
             {
                 lastKnot.isPointedAt = false;
             }
         }
     }
     else
     {
         isHitting = false;
         if (lastKnot)
         {
             lastKnot.isPointedAt = false;
         }
     }
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        bool triggerValue;

        if (grabPinchAction.GetState(handType) &&
            MovementRod.instance.isHitting &&
            !isMoving)
        {
            Debug.Log("Trigger button is pressed.");

            DestKnot         = MovementRod.instance.Hit.transform.GetComponent <MovementKnot>();
            LerpStart        = transform.position;
            LerpDest         = MoveToKnot(DestKnot);
            isMoving         = true;
            Vignette.enabled = true;
        }

        if (fraction < 1 && isMoving == true)
        {
            fraction          += Time.deltaTime * LerpSpeed;
            transform.position = Vector3.Lerp(LerpStart, LerpDest, fraction);


            if (fraction >= 1)
            {
                fraction = 0;
                isMoving = false;
                CurrentKnot.PlayerExited();
                CurrentKnot = DestKnot;
                CurrentKnot.PlayerEntered();
                Vignette.enabled = false;
            }
        }
        //MovementClamp();
    }
Esempio n. 3
0
    private Vector3 MoveToKnot(MovementKnot knot)
    {
        if (knot == CurrentKnot)
        {
            Debug.Log("same knot, not moving there"); return(Vector3.zero);
        }

        float   distance  = Vector3.Distance(knot.InitialPosition, CurrentKnot.InitialPosition);//TODO: replace by static distance, cuz rooms have same size - nah fam
        Vector3 direction = (knot.InitialPosition - CurrentKnot.InitialPosition).normalized;

        return(PlayerBody.position + (direction * distance));
    }