Advertisement
Guest User

UA comment on CollectPapers script doesn't work in Unity5

a guest
May 28th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. *I wanted the game to quit once the player has collected all the object, and I didn't want the hud.* : in that case, don't use OnGUI, but check where the total is incremented. This happens at line 45, where the debug is :
  2.  
  3. //Debug.Log( "A pokeball was picked up. Total Pokeballs = " + papers );
  4. if ( papers >= papersToWin ) // maximum total is reached, do something...
  5. {
  6. Application.Quit(); // loadLevel, whatever
  7. }
  8.  
  9. *I added an instant reload trigger on contact* : always Debug to see what is happening in your scripts.
  10.  
  11. function OnTriggerEnter (player : Collider)
  12. {
  13. // What entered the trigger?
  14. Debug.Log( player.tag + "(tag) " + player.name + "(name) has entered the trigger of " + gameObject.name );
  15.  
  16. if(player.tag=="Player")
  17. {
  18. Application.LoadLevel(Application.loadedLevel);
  19. }
  20. }
  21.  
  22. make sure the conditions are met to be able to use triggers : http://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
  23.  
  24. **Notes:** Trigger events are only sent if one of the colliders also has a rigidbody attached.
  25.  
  26. Apart from that, it is impossible to provide any more help : *I actually managed to get it to work.* So this question should be closed.
  27.  
  28. Please ask a new question (preferably in the forums, as UA is broken and I don't receive notifications), with information regarding : the setup; scripts; desired behaviour and current behaviour. Good Luck with your project.
  29.  
  30.  
  31. Edit : dammit, now the simple act of formatting text for italics and code doesn't even work. UA is totally broken....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement