Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update () {
- PlaneProject = Vector3.ProjectOnPlane(transform.position, Pole.up);
- Direction = (Pole.position - PlaneProject).normalized;
- Dot = Vector3.Dot(Pole.forward, Direction);
- PrevAngle = Angle;
- Angle = Vector3.SignedAngle(Direction, Pole.forward, Vector3.up);
- TotalAngle += Angle - PrevAngle;
- CheckDirection();
- }
- private void CheckDirection(){
- if(PrevAngle > Angle){
- //clockwise
- if(PrevAngle > 0 && Angle < 0 && TotalAngle > -50 && TotalAngle < 50){
- //completed a revolution
- wraps++;
- ResizeRope();
- } else {
- clockwise = true;
- }
- }
- if(PrevAngle < Angle){
- if(PrevAngle < 0 && Angle > 0 && TotalAngle > -50 && TotalAngle < 50){
- //completed a revoltuion
- wraps--;
- ResizeRope();
- } else {
- clockwise = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement