Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.W) && cursor != null)
        {
            if (rope.restLength > minLength)
            {
                cursor.ChangeLength(rope.restLength - 1f * Time.deltaTime);
            }
        }

        if (Input.GetKey(KeyCode.S) && cursor != null)
        {
            cursor.ChangeLength(rope.restLength + 1f * Time.deltaTime);
        }

        if (Input.GetKey(KeyCode.A))
        {
            rope.transform.Translate(Vector3.left * Time.deltaTime, Space.World);
        }

        if (Input.GetKey(KeyCode.D))
        {
            rope.transform.Translate(Vector3.right * Time.deltaTime, Space.World);
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            if (cursor.rope.RestLength > 6.5f)
            {
                cursor.ChangeLength(cursor.rope.RestLength - 1f * Time.deltaTime);
            }
        }

        if (Input.GetKey(KeyCode.S))
        {
            cursor.ChangeLength(cursor.rope.RestLength + 1f * Time.deltaTime);
        }

        if (Input.GetKey(KeyCode.A))
        {
            transform.Rotate(0, Time.deltaTime * 15f, 0);
        }

        if (Input.GetKey(KeyCode.D))
        {
            transform.Rotate(0, -Time.deltaTime * 15f, 0);
        }
    }
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (!rope.isLoaded)
            {
                LaunchHook();
            }
            else
            {
                DetachHook();
            }
        }

        if (rope.isLoaded)
        {
            if (Input.GetKey(KeyCode.W))
            {
                cursor.ChangeLength(rope.restLength - hookExtendRetractSpeed * Time.deltaTime);
            }
            if (Input.GetKey(KeyCode.S))
            {
                cursor.ChangeLength(rope.restLength + hookExtendRetractSpeed * Time.deltaTime);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            if (rope.RestLength > minLength)
            {
                cursor.ChangeLength(rope.RestLength - 1f * Time.deltaTime); //reduces rope length
            }
        }

        if (Input.GetKey(KeyCode.S))
        {
            cursor.ChangeLength(rope.RestLength + 1f * Time.deltaTime); //increases rope length
        }

        if (Input.GetKey(KeyCode.A))
        {
            rope.transform.Translate(Vector3.left * Time.deltaTime, Space.World);
        }

        if (Input.GetKey(KeyCode.D))
        {
            rope.transform.Translate(Vector3.right * Time.deltaTime, Space.World);
        }
    }
Esempio n. 5
0
 public void IncreaseLength(int addLength)
 {
     // cursor.cursorMu = 1f;
     Debug.Log($"Increasing Length from {length} to {length + addLength}");
     length += addLength;
     cursor.ChangeLength(length);
 }
    // Update is called once per frame
    void Update()
    {
        // Shortens the rope when A is held down
        if (OVRInput.Get(OVRInput.RawButton.A) || Input.GetKey(KeyCode.W))
        {
            if (rope.restLength > 2.5f)
            {
                cursor.ChangeLength(rope.restLength - 1f * Time.deltaTime);
            }
        }

        // Lengthens the rope when B is held down
        if (OVRInput.Get(OVRInput.RawButton.B) || Input.GetKey(KeyCode.S))
        {
            cursor.ChangeLength(rope.restLength + 1f * Time.deltaTime);
        }
    }
    // Update is called once per frame
    void Update()
    {
        //if (Input.GetKey(KeyCode.S))
        //{
        //    cursor.ChangeLength(rope.RestLength + speed * Time.deltaTime);
        //}

        cursor.ChangeLength(rope.RestLength + speed * Time.deltaTime);
    }
Esempio n. 8
0
 //Controls the length of rope, it get it's orders from the Action<bool> RopeSize
 public void RopeSizeController(bool direction)
 {
     if (direction)
     {
         print("Front");
         if (rope.RestLength > minLength)
         {
             cursor.ChangeLength(rope.RestLength - 1f * ropeSpeed * Time.deltaTime);
         }
     }
     else
     {
         print("Back");
         if (rope.RestLength < maxLength)
         {
             cursor.ChangeLength(rope.RestLength + 1f * Time.deltaTime * ropeSpeed);
         }
     }
 }
Esempio n. 9
0
 /// <summary>
 /// ajout ou supprime des particules de la rope, à un evitesse donné
 /// </summary>
 public void ChangeParticleInRope(bool addition, float speed, bool vibration = false)
 {
     if (addition)
     {
         if (vibration)
         {
             AddVibration(true);
         }
         cursor.ChangeLength(rope.RestLength + speed * Time.deltaTime);
     }
     else
     {
         if (vibration)
         {
             AddVibration(false);
         }
         cursor.ChangeLength(rope.RestLength - speed * Time.deltaTime);
     }
 }
Esempio n. 10
0
    private IEnumerator LaunchGrappleIE()
    {
        hookTrf.parent     = null;
        hookRB.isKinematic = true;
        state = State.Launching;
        hook.ToggleActivate(true);

        Vector3 target = player.position + player.forward * distance;

        target.y = hookHolder.position.y;

        Vector3 lastPosition = hookTrf.position;

        while (true)
        {
            if (state == State.Grabbing)
            {
                break;
            }

            Vector3 newPos = Vector3.MoveTowards(hookTrf.position, target, speed * Time.fixedDeltaTime);
            hookRB.MovePosition(newPos);

            float length = Vector3.Distance(lastPosition, hookTrf.position);
            lastPosition = hookTrf.position;
            cursor.ChangeLength(rope.restLength + length / 2f);

            if (Vector3.Distance(hookTrf.position, target) < 0.001f)
            {
                break;
            }

            yield return(new WaitForFixedUpdate());
        }

        hookRB.isKinematic = false;
        hook.ToggleActivate(false);

        StartCoroutine(RetrieveGrappleIE());
    }
Esempio n. 11
0
 /// <summary>
 /// Increase the length of the scarf
 /// </summary>
 public void AddToScarf()
 {
     cursor.ChangeLength(rope.RestLength + speedIncrease * Time.deltaTime);
 }
Esempio n. 12
0
 /// <summary>
 /// Like extending or retracting a winch.
 /// </summary>
 public void ChangeRopeLength(float changeAmount)
 {
     // the cursor will automatically add/remove/modify constraints and particles as needed to obtain the new length.
     cursor.ChangeLength(rope.RestLength + changeAmount);
     //UpdateTethers();
 }
Esempio n. 13
0
 void Start()
 {
     cursor = GetComponentInChildren <ObiRopeCursor>();
     rope   = cursor.GetComponent <ObiRope>();
     cursor.ChangeLength(length);
 }