Hi! I’m very new to this and I’m sure this is really simple, but I haven’t been able to piece it together from the documentation and searching examples.
I’m trying to use WaitForSeconds in an IEnumerator to let an object move a certain amount of time before I stop it and then break it, but it just starts the break sequence right away and I don’t understand how to get it to work.
void Throw(){
myRigidbody.isKinematic = false;
myCollider.isTrigger = true;
myRigidbody.AddForce (new Vector3 (player.lastMove.x * 30f, player.lastMove.y * 30f, 0f), ForceMode2D.Impulse);
myRigidbody.gravityScale = 1f;
StartCoroutine (HangOn(10f));
Break ();
}
void Break(){
//gameObject.GetComponent<Animator>().SetBool("Break", true);
breaking = true;
anim.SetBool ("Break", breaking);
}
IEnumerator HangOn(float waitTime){
yield return new WaitForSeconds (waitTime);
}
From what I’ve read, this is as simple as it gets. I really just need the HangOn IEnumerator to give the object time to travel a ways before breaking it.
Please help!
![]()