1234567891011121314151617181920212223242526272829 |
- 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;
- 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;
- }
- }
|