Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement