SHARE
TWEET

Untitled

a guest Oct 15th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Update () {
  2.         PlaneProject = Vector3.ProjectOnPlane(transform.position, Pole.up);
  3.         Direction = (Pole.position - PlaneProject).normalized;
  4.         Dot = Vector3.Dot(Pole.forward, Direction);
  5.         PrevAngle = Angle;
  6.         Angle = Vector3.SignedAngle(Direction, Pole.forward, Vector3.up);
  7.         TotalAngle += Angle - PrevAngle;
  8.  
  9.         CheckDirection();
  10.     }
  11.  
  12.     private void CheckDirection(){
  13.         if(PrevAngle > Angle){
  14.             //clockwise
  15.             if(PrevAngle > 0 && Angle < 0 && TotalAngle > -50 && TotalAngle < 50){
  16.                 //completed a revolution
  17.                 wraps++;
  18.                 ResizeRope();
  19.             } else {
  20.                 clockwise = true;
  21.             }
  22.         }
  23.  
  24.         if(PrevAngle < Angle){
  25.             if(PrevAngle < 0 && Angle > 0 && TotalAngle > -50 && TotalAngle < 50){
  26.                 //completed a revoltuion
  27.                 wraps--;
  28.                 ResizeRope();
  29.             } else {
  30.                 clockwise = false;
  31.             }
  32.         }
  33.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top