Coin.cs 747 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Coin : MonoBehaviour {
  5. Rigidbody _rig;
  6. // Use this for initialization
  7. void Start () {
  8. _rig = GetComponent<Rigidbody>();
  9. _rig.AddForce(Vector3.up*300);
  10. StartCoroutine(rotate());
  11. Destroy(gameObject, 3);
  12. }
  13. IEnumerator rotate()
  14. {
  15. Quaternion rotate = transform.rotation;
  16. Vector3 look = Vector3.zero;
  17. while (true)
  18. {
  19. look += new Vector3(0, 100, 0);
  20. rotate.SetLookRotation(look);
  21. transform.rotation = rotate;
  22. yield return new WaitForFixedUpdate();
  23. }
  24. }
  25. // Update is called once per frame
  26. void Update () {
  27. }
  28. }