Search Unity

Drop in/ Drop out Co-op

Discussion in 'Scripting' started by bonechill, Nov 21, 2014.

  1. bonechill

    bonechill

    Joined:
    Aug 3, 2013
    Posts:
    11
    I am trying to make it so that when you press the Start button on the Xbox Controller, it brings up a menu with various options, when you click the Co-op Mode button, it instantiates a second character and makes the camera take up half the screen, and has a second camera take up the other half. but when I click the button, it doesn't change the camera size. I can't figure it out.

    1. #pragma strict
    2. varSplit:boolean=false;
    3. varTurnOnGUI:boolean=false;
    4. var camOne :boolean;
    5. var camTwo :boolean;
    6. functionStart(){
    7. Camera.main.rect =newRect(0,0,1,1);
    8. }
    9. functionUpdate(){
    10. if(Input.GetButtonDown("Start_1")){
    11. if(TurnOnGUI==false){
    12. TurnOnGUI=true;
    13. }
    14. elseif(TurnOnGUI==true){
    15. TurnOnGUI=false;
    16. }
    17. }
    18. }
    19. functionSwitch(){
    20. if(Split==false){
    21. if(camOne ==true){
    22. Camera.main.rect =Rect(0,0,.5,1);
    23. Split=true;
    24. Debug.Log("Two Player");
    25. WaitForSeconds(1);
    26. }
    27. if(camTwo ==true){
    28. Camera.main.rect =Rect(.5,0,.5,1);
    29. Split=true;
    30. Debug.Log("Two Player");
    31. WaitForSeconds(1);
    32. }
    33. }
    34. elseif(Split==true){
    35. if(camOne ==true){
    36. Camera.main.rect =Rect(0,0,1,1);
    37. Split=false;
    38. Debug.Log("One Player");
    39. WaitForSeconds(1);
    40. }
    41. }
    42. }
    43. functionOnGUI(){
    44. if(TurnOnGUI==true){
    45. if(camOne ==true){
    46. if(GUI.Button(Rect(Screen.width *.1,Screen.height *.2,Screen.width *.3,Screen.height *.1),"Continue")){
    47. TurnOnGUI=false;
    48. }
    49. if(GUI.Button(Rect(Screen.width *.1,Screen.height *.35,Screen.width *.3,Screen.height *.1),"Co-op Mode")){
    50. Switch();
    51. TurnOnGUI=false;
    52. }
    53. GUI.Button(Rect(Screen.width *.1,Screen.height *.5,Screen.width *.3,Screen.height *.1),"Settings");{
    54. }
    55. GUI.Button(Rect(Screen.width *.1,Screen.height *.65,Screen.width *.3,Screen.height *.1),"Credits");{
    56. }
    57. GUI.Button(Rect(Screen.width *.1,Screen.height *.8,Screen.width *.3,Screen.height *.1),"Quit");{
    58. Application.Quit();
    59. }
    60. }
    61. }
    62. else{
    63. }
    64. }