Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Rotator
- {
- Vector3 axis;
- float speed;
- float ang = 0;
- GameObject obj;
- public Rotator(Vector3 _axis, float _speed, GameObject _obj)
- {
- axis = _axis;
- speed = _speed;
- obj = _obj;
- }
- public void Rotate()
- {
- obj.transform.rotation = Quaternion.AngleAxis(ang, axis);
- if (ang + speed >= 360f)
- ang += speed - 360f;
- else
- ang += speed;
- }
- }
- class Head : MonoBehaviour
- {
- Rotator rot;
- public Head(GameObject head)
- {
- rot = new Rotator(Vector3.up, 0.5f, head);
- }
- private void Update()
- {
- rot.Rotate();
- }
- }
- public class Obamatron : MonoBehaviour
- {
- public GameObject head;
- public GameObject neck;
- public GameObject body;
- public GameObject lleg;
- public GameObject lfoot;
- public GameObject rleg;
- public GameObject rfoot;
- public GameObject larm;
- public GameObject lhand;
- public GameObject rarm;
- public GameObject rhand;
- // Set this from your code somewhere
- public GameObject[] players;
- Head hed;
- // Start is called before the first frame update
- void Start()
- {
- //
- //
- // CHANGE THIS
- //
- ///
- players = new GameObject[1];
- players[0] = GameObject.FindGameObjectWithTag("Player");
- hed = new Head(head);
- }
- // Update is called once per frame
- void Update()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment