Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Why is my "yield" statement stopping my script?

$
0
0
Hi, I can't seem to figure out what is wrong with my script. I am creating a roller ball game and I want the ball to disappear when it triggers a hit on the wall. Everything works great separately but when I add a line to get rid of the camera follow script, the script stops at my "yield" command. If I remark out the "yield" command, it works fine but there isn't enough time to complete the explosion and sound before it loads the "reset" level. Can someone please take a look at my script and tell me why it stops at "yield"? Thank you so much!!! Tom #pragma strict var explosionEnd : Transform; function Start () { } function Update () { } function OnTriggerEnter (myTrigger : Collider) { if(myTrigger.gameObject.name == "WallSide") { //Create explosion wherer the ball is (not done yet) Instantiate (explosionEnd); Debug.Log ("I hit something."); //Make the RollerBall disapear Destroy (gameObject.Find("Player")); //Get rid of the camera script so it stops trying to find the RollerBall Component.Destroy(Camera.main.gameObject.GetComponent("CameraFollow")); Debug.Log ("This is the second message."); //Wait for the explosion and sound to complete yield WaitForSeconds(2); //Load the start over menu level Application.LoadLevel ("Level 7 Reset"); Debug.Log ("This is a third message."); } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>