private IEnumerator WaitAndSwing(float waitTime, Vector3 rotation, float thrust) { _swing(rotation, thrust); yield return(new WaitForSeconds(waitTime)); currentState = Helper.BallState.Swinged; }
// Update is called once per frame void Update() { Debug.Log("Magnitude: " + rb.velocity.magnitude); if (currentState.Equals(Helper.BallState.Swinged)) { if (rb.velocity.magnitude < 0.1f) { ResetForce(); currentState = Helper.BallState.Stationary; } } }
public void Swing(Vector3 rotation, float thrust) { currentState = Helper.BallState.Swinging; StartCoroutine(WaitAndSwing(0.6f, rotation, thrust)); }
// Use this for initialization void Start() { rb = gameObject.GetComponent <Rigidbody>(); currentState = Helper.BallState.Stationary; }