bird1000000

Untitled

Dec 6th, 2020
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1.  class Rotator
  2.     {
  3.         Vector3 axis;
  4.         float speed;
  5.         float ang = 0;
  6.         GameObject obj;
  7.  
  8.         public Rotator(Vector3 _axis, float _speed, GameObject _obj)
  9.         {
  10.             axis = _axis;
  11.             speed = _speed;
  12.             obj = _obj;
  13.         }
  14.  
  15.         public void Rotate()
  16.         {
  17.             obj.transform.rotation = Quaternion.AngleAxis(ang, axis);
  18.  
  19.             if (ang + speed >= 360f)
  20.                 ang += speed - 360f;
  21.             else
  22.                 ang += speed;
  23.         }
  24.     }
  25.  
  26.  
  27.     class Head : MonoBehaviour
  28.     {
  29.         Rotator rot;
  30.         public Head(GameObject head)
  31.         {
  32.             rot = new Rotator(Vector3.up, 0.5f, head);
  33.         }
  34.        
  35.         private void Update()
  36.         {
  37.             rot.Rotate();
  38.         }
  39.     }
  40.  
  41.  
  42.  
  43.     public class Obamatron : MonoBehaviour
  44.     {
  45.         public GameObject head;
  46.         public GameObject neck;
  47.         public GameObject body;
  48.  
  49.         public GameObject lleg;
  50.         public GameObject lfoot;
  51.         public GameObject rleg;
  52.         public GameObject rfoot;
  53.  
  54.         public GameObject larm;
  55.         public GameObject lhand;
  56.         public GameObject rarm;
  57.         public GameObject rhand;
  58.  
  59.         // Set this from your code somewhere
  60.         public GameObject[] players;
  61.  
  62.         Head hed;
  63.  
  64.  
  65.         // Start is called before the first frame update
  66.         void Start()
  67.         {
  68.             //
  69.             //
  70.             // CHANGE THIS
  71.             //
  72.             ///
  73.             players = new GameObject[1];
  74.             players[0] = GameObject.FindGameObjectWithTag("Player");
  75.  
  76.             hed = new Head(head);
  77.         }
  78.  
  79.         // Update is called once per frame
  80.         void Update()
  81.         {
  82.  
  83.  
  84.         }
  85.     }
Advertisement
Add Comment
Please, Sign In to add comment