Esempio n. 1
0
 void FixedUpdate()
 {
     if (pull)
     {
         if (pulltimer > 0)
         {
             pulltimer -= Time.fixedDeltaTime;
         }
         else
         {
             if (pullable)
             {
                 pullable.Pull(transform.position, power);
                 pullable = null;
             }
             else
             {
                 physics.Pull(target, power);
             }
             lineRenderer.enabled = false;
             pull = false;
         }
     }
     if (cooldown)
     {
         if (cooldowntimer > 0)
         {
             cooldowntimer -= Time.fixedDeltaTime;
         }
         else
         {
             cooldown = false;
         }
     }
 }
Esempio n. 2
0
    public void UseGrapplingHook()
    {
        if (!cooldown)
        {
            var v = transform.InverseTransformPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition));
            v.z = 0;
            var        ray = new Ray(transform.position, v);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, length))
            {
                target               = hit.point;
                pulltimer            = Vector3.Distance(transform.position, target) * timeToPull;
                pull                 = true;
                lineRenderer.enabled = true;

                cooldowntimer = cooldownTime;
                cooldown      = true;
                pullable      = hit.collider.GetComponent <PullableBehaviour>();
            }
        }
    }