12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using UnityEngine;
- public class Ball : MonoBehaviour
- {
- public bool IsInUse { get; private set; }
- public float speed = 5f;
- // Start is called before the first frame update
- void Start()
- {
- }
- public void Recenter()
- {
- var component = GetComponent<Rigidbody>();
- component.velocity = Vector3.zero;
- component.transform.position = Vector3.zero;
- IsInUse = false;
- }
- public void Kickoff()
- {
- float sx = Random.Range(0, 2) == 0 ? -1 : 1;
- float sz = Random.Range(0, 2) == 0 ? -1 : 1;
- GetComponent<Rigidbody>().velocity = new Vector3(speed * sx, 0f, speed * sz);
- IsInUse = true;
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- }
|