Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
- public class RingRotation : MonoBehaviour
- {
- public float startSpeed = 40;
- public float endSpeed = 10;
- public int degrees = 0;
- public int rotationdegrees = 0;
- public bool justadded;
- public Rigidbody RB;
- public TMP_Text LevelAdd;
- // Start is called before the first frame update
- void Start()
- {
- StartCoroutine(Spin());
- }
- // Update is called once per frame
- void Update()
- {
- }
- IEnumerator Spin()
- {
- LevelAdd.text = GameInstance.goalring.ToString();
- RB.angularVelocity = new Vector3(0, startSpeed, 0);
- while (rotationdegrees < 10)
- {
- if (Mathf.Abs(transform.rotation.y) > 0.9f && justadded == false)
- {
- rotationdegrees += 1;
- justadded = true;
- RB.angularVelocity = new Vector3(0, RB.angularVelocity.y - 1, 0);
- }
- if (Mathf.Abs(transform.rotation.y) < 0.9f)
- {
- justadded = false;
- }
- yield return new WaitForSeconds(Time.deltaTime);
- }
- RB.angularVelocity = Vector3.zero;
- transform.rotation = Quaternion.Euler(0, 180, 0);
- GameInstance.goalring += 1;
- LevelAdd.text = GameInstance.goalring.ToString();
- }
- }
Add Comment
Please, Sign In to add comment