示例#1
0
    private IEnumerator WaitAndSwing(float waitTime, Vector3 rotation, float thrust)
    {
        _swing(rotation, thrust);
        yield return(new WaitForSeconds(waitTime));

        currentState = Helper.BallState.Swinged;
    }
示例#2
0
 // 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;
         }
     }
 }
示例#3
0
 public void Swing(Vector3 rotation, float thrust)
 {
     currentState = Helper.BallState.Swinging;
     StartCoroutine(WaitAndSwing(0.6f, rotation, thrust));
 }
示例#4
0
 // Use this for initialization
 void Start()
 {
     rb           = gameObject.GetComponent <Rigidbody>();
     currentState = Helper.BallState.Stationary;
 }