Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class RotateRandom : MonoBehaviour
- {
- bool noTarget = true;
- Quaternion qTo;
- float rotateSpeed = 3.0f;
- float timer = 0.0f;
- private void Start()
- {
- qTo = Quaternion.Euler(new Vector3(0.0f, Random.Range(135.0f, 225.0f), 0.0f));
- }
- private void Update()
- {
- timer += Time.deltaTime;
- if (noTarget == true)
- {
- if (timer > 2)
- {
- qTo = Quaternion.Euler(new Vector3(0.0f, Random.Range(135.0f, 225.0f), 0.0f));
- timer = 0.0f;
- }
- transform.rotation = Quaternion.Slerp(transform.rotation, qTo, Time.deltaTime * rotateSpeed);
- }
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class RotateRandom : MonoBehaviour
- {
- bool noTarget = true;
- Quaternion qTo;
- float speed = 1.25f;
- float rotateSpeed = 3.0f;
- float timer = 0.0f;
- int counter = 0;
- private void Start()
- {
- qTo = Quaternion.Euler(new Vector3(0.0f, Random.Range(90.0f, 270.0f), 0.0f));
- }
- private void Update()
- {
- timer += Time.deltaTime;
- if (noTarget == true)
- {
- if (timer > 2)
- {
- var rand = Random.Range(90.0f, 270.0f);
- counter += 1;
- if (rand >= 90 && rand <= 180)
- {
- if(counter == 2)
- {
- rand = Random.Range(180.0f, 270.0f);
- counter = 0;
- }
- }
- if (rand >= 270 && rand >= 180)
- {
- if (counter == 2)
- {
- rand = Random.Range(90.0f, 180.0f);
- }
- counter = 0;
- }
- qTo = Quaternion.Euler(new Vector3(0.0f, rand, 0.0f));
- timer = 0.0f;
- }
- transform.rotation = Quaternion.Slerp(transform.rotation, qTo, Time.deltaTime * rotateSpeed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement