Search Unity

Victory screen not showing...

Discussion in '2D' started by seankellygaller5, Jul 31, 2019.

  1. seankellygaller5

    seankellygaller5

    Joined:
    Jul 13, 2019
    Posts:
    16
    hello, my name is SeanKelly Galler. I'm a Student at Darfield High school. currently, I'm having trouble making my Victory message screen to appear. First off this image right here is my victory message I wanted to show once the player reached the finish line.

    1.PNG

    however when the player reach the finish line the victory screen doesn't show up...
    2.PNG

    if you want to help me here's the info i can give it to you!
    4.PNG
    5.PNG
    3.PNG

    if you want to help me feel free to talk to me any help would be a pleasure!
    and also free to ask me if you need more info about my game!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,454
    You simply need to debug. Try putting a breakpoint in the OnTriggerEnter2D to see if you ever enter there or add a "Debug.Log" to output something to the control. Without that you have no idea if the logic in the callback is wrong or has a problem or if the trigger isn't working. If the trigger isn't working then it'll be because the two colliders don't overlap or they are not set to collide with each other. You may find the triggers is working and the logic in there does but the problem is with the victory screen.

    It's best to figure these steps out first before asking for help. If you've already done this then it's best to state what you've tried already which'll make helping you quicker.

    So to start, check to see if the trigger callback happens.

    Hope that helps.
     
  3. seankellygaller5

    seankellygaller5

    Joined:
    Jul 13, 2019
    Posts:
    16

    um is it possible to just give my project to you to look at the problem? since it will be much easier to quicker to find a problem? we've done this before can we do it again? plz?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,454
    Sure, send me a link or upload it here with instructions on how I should reproduce the issue.
     
    seankellygaller5 likes this.
  5. seankellygaller5

    seankellygaller5

    Joined:
    Jul 13, 2019
    Posts:
    16
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,454
    This would be helpful.
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,454
    So I figured out how to reproduce it but it does hit the trigger block in "Game Lv3" and the trigger callback happens which I guess you know because "victorytext" is output to the console (btw: you should really mention this as it enables quicker help for you):

    Code (CSharp):
    1.     public void Victorygame()
    2.     {
    3.         Destroy(gameObject);
    4.         GameLevelManager.reStartTheGame();
    5.         Animator victoryAnimator = Victorytext.GetComponent<Animator>();
    6.         victoryAnimator.SetTrigger("victory");
    7.         Debug.Log("victorytext");
    8.  
    9.     }
    10.  
    When you do this you get an error to the console because the GameObject the animator/text are on are deactivated so you don't see your text.

    As a hack I simply activate the GameObject but you'll need to figure out when that should be done and then maybe deactivated:
    Code (CSharp):
    1.     public void Victorygame()
    2.     {
    3.         Destroy(gameObject);
    4.         GameLevelManager.reStartTheGame();
    5.         Animator victoryAnimator = Victorytext.GetComponent<Animator>();
    6.         Victorytext.gameObject.SetActive(true); // <- Make sure the thing is active.
    7.         victoryAnimator.SetTrigger("victory");
    8.         Debug.Log("victorytext");
    9.     }
    10.  
    Hope this helps.
     
    seankellygaller5 likes this.
  8. seankellygaller5

    seankellygaller5

    Joined:
    Jul 13, 2019
    Posts:
    16
    t
    hank you sir you're the best! i hope i could smashedthat like button!
     
    MelvMay likes this.