Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private GameObject myobject;
- public float timeElapsed =0;
- public float delay = 3.0f;
- float OO = 0.0f;
- void Start () {
- myobject = GameObject.Find ("rightarm").gameObject;
- }
- void Update () {
- timeElapsed += Time.deltaTime;
- Debug.Log (timeElapsed);
- if (timeElapsed >= delay) {
- OO = 30.0f;
- timeElapsed = 0;
- if (myobject.renderer.enabled == false) {
- myobject.renderer.enabled = true;
- }
- myobject.transform.Rotate (OO, 0.0f, 0.0f);
- }
- else
- {
- myobject.transform.Rotate (-OO,0.0f, 0.0f );
- }
- }
- void Update () {
- timeElapsed += Time.deltaTime;
- Debug.Log (timeElapsed);
- if (timeElapsed >= delay) {
- OO = 30.0f;
- timeElapsed = 0;
- if (myobject.renderer.enabled == false) {
- myobject.renderer.enabled = true;
- }
- myobject.transform.rotation = Quaternion.Euler (OO, 0.0f, 0.0f);
- }
- else
- {
- myobject.transform.rotation = Quaternion.Euler (-OO, 0.0f, 0.0f);
- }
- // Specify how many degrees you want to rotate from the initial orientation.
- public Vector3 amplitude = new Vector3(30, 0, 0);
- // Specify how many seconds a complete loop should take.
- public float period = 6f;
- // Cache initial orientation so we can rotate relative to that pose.
- Quaternion _initialOrientation;
- // Perform caching on Start.
- void Start() {
- _initialOrientation = transform.localRotation;
- }
- void Update() {
- // Calculate how far along we should be in the wave.
- float phase = Mathf.PI * 2f * Time.time/period;
- // Calculate the angle at this part of the wave.
- Vector3 angle = amplitude * Mathf.Cos(phase);
- // Rotate by angle relative to our initial orientation.
- transform.localRotation = _initialOrientation * Quaternion.Euler(angle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement