Search Unity

I need help with my 2D game

Discussion in '2D' started by Vonfaris, Jun 20, 2019.

  1. Vonfaris

    Vonfaris

    Joined:
    Jun 20, 2019
    Posts:
    1
    So, I'm quite new to Unity and I'm trying to get better at it, I've followed a youtube series on how to make a 2D game and I'm currently in the process of making of my own game.
    I'm trying to make it so when a dialogue pops up, my character stops the actual ANIMATIONS from moving.
    I've already made it so he stops moving but the actual animations keep on going as if he's moving.
    It's a touch game and there's also a joystick involved which you can move around with touch and that's the main movement control. That gets in the way of the dialogue activation though. I have a game object that represents the dialogue zone with a script attached to it that has this typed in it:
    Code (CSharp):
    1. public void OnTriggerStay2D(Collider2D other)
    2.     {
    3.         if (other.gameObject.name == "Player")
    4.         {
    5.                 if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Ended)
    6.                 {
    7.                     if (!dMAn.dialogActive)
    8.                     {
    9.                         dMAn.dialogLines = dialogueLines;
    10.                         dMAn.currentLine = 0;
    11.                         dMAn.ShowDialogue();
    12.                     }
    13.                 }
    14.         }
    15.     }
    and this part which is in the Dialogue Manager script which I believe you need the info about aswell to recommend a fix to my issue:

    Code (CSharp):
    1. if (dialogActive && (Input.GetTouch(0).phase == TouchPhase.Began))
    2.         {
    3.             //dBox.SetActive(false);
    4.             //dialogueActive = false;
    5.  
    6.             currentLine++;
    7.         }
    8.  
    9.         if(currentLine >= dialogLines.Length)
    10.         {
    11.             dBox.SetActive(false);
    12.             dialogActive = false;
    13.  
    14.             currentLine = 0;
    15.             thePlayer.canMove = true;
    16.         }
    So how do I make it so when the player stops and obviously I stop using my joystick when entering the dialogue zone the actual dialogue box doesn't pop up instantly, but I have to tap again for it to actually open properly, and also stopping the player's animations?
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,639
    About the animations:
    I'm sure in whatever Youtube series you are watching they explain how to update the animator state. Your animation should typically have an "Idle" state in which your character is standing still, so all you'd need to do is change your animator state to the "Idle" state.