Ball.cs 824 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using UnityEngine;
  5. public class Ball : MonoBehaviour
  6. {
  7. public float speed = 5f;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. //Thread.Sleep(5000);
  12. //float sx = Random.Range(0, 2) == 0 ? -1 : 1;
  13. //float sz = Random.Range(0, 2) == 0 ? -1 : 1;
  14. //GetComponent<Rigidbody>().velocity = new Vector3(speed * sx, 0f, speed * sz);
  15. }
  16. public void Init()
  17. {
  18. float sx = Random.Range(0, 2) == 0 ? -1 : 1;
  19. float sz = Random.Range(0, 2) == 0 ? -1 : 1;
  20. GetComponent<Rigidbody>().velocity = new Vector3(speed * sx, 0f, speed * sz);
  21. }
  22. // Update is called once per frame
  23. void Update()
  24. {
  25. }
  26. }