Splitscreen Issues

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
splinedrew
Posts: 13
Joined: Tue Mar 15, 2022 8:53 pm

Splitscreen Issues

Post by splinedrew »

Hello there!

I have most things almost working and it's feeling great! I can have two independent conversations with different NPCs, and depending on who you are in the game you get a different conversation. I am getting hung up on one snag now. Which is that I can have two independent conversations, but when I try to have two conversations at the same time, the second conversation that is started really messes with the previous conversation that started.

I am using Rewired, and have custom input logic for the Continue and Response buttons so each player is handled independently. I am using Opsive for Inventory Management, and using some logic from them to handle two event systems with an event system manager.

I do have Allow Simultaneous Conversations enabled, and Custom Panels set for the subtitle and menu panels. I have tried hard to debug where things go wrong, and I added a debug statement to the UIPanel script that runs everytime the panel runs OnHidden. When the second conversation starts, everything loads up fine, but when you continue through to the next line of Dialogue this is where things break.

Here is a video of it in action: https://streamable.com/1s84s1
The second time I talk to the NPCs you can see that when P1 presses continue it starts trying to close panels and messes with P2.

So if P1 presses continue, then this statement prints for the P2 panel:

Code: Select all

Hide requested!
UnityEngine.Debug:Log (object,UnityEngine.Object)
PixelCrushers.UIPanel:OnHidden () (at Assets/Plugins/Pixel Crushers/Common/Scripts/UI/UIPanel.cs:266)
PixelCrushers.UIAnimatorMonitor/<WaitForAnimation>d__13:MoveNext () (at Assets/Plugins/Pixel Crushers/Common/Scripts/UI/UIAnimatorMonitor.cs:105)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
Is there any bools or something I might be overlooking that can prevent the 2nd player panel from getting that message. Or if the message comes in could I verify that it came from the correct sender before hiding the panel?

I think as a next step i might have to make my own classes that inherit and override the StandardUISubtitlePanel and the StandardUIMenu panel, so I can hook it up to to my event system manager correctly. And maybe in that custom script I can provide any additional logic that might keep these menus open. Sorry for the novel and I appreciate anything that might point me in the right direction!
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Splitscreen Issues

Post by Tony Li »

Hi,

How are your continue buttons configured? Do they call their subtitle panel's OnContinue() method?
splinedrew
Posts: 13
Joined: Tue Mar 15, 2022 8:53 pm

Re: Splitscreen Issues

Post by splinedrew »

Hey there,

Each button is assigned this script:

Code: Select all

public class RewiredInputButtonHotkey : MonoBehaviour
{
    //Exposed fields
    [SerializeField] string actionName;
    [SerializeField] IntVariable RewiredPlayerID;//This is my way of handling rewired player IDs with scriptable objs
    [SerializeField] Button button;
    protected bool initialized;
    Player m_player;

    private void Awake()
    {
        Initialize();
    }

    protected virtual void Initialize()
    {
        if (initialized) return;
        RewiredPlayerID.OnValueChanged += UpdateRewiredPlayer;
        UpdateRewiredPlayer(RewiredPlayerID.GetValue());
        initialized = true;
    }

    private void UpdateRewiredPlayer(int ID)
    {
        m_player = ReInput.players.GetPlayer(ID);
        if (m_player == null) Debug.LogWarning("Didn't find a Rewired player #" + ID, this);
    }

    private void Update()
    {
        if (m_player != null)
        {
            if (m_player.GetButtonDown(actionName))
            {
                OnPress();
            }
        }
    }

    public virtual void OnPress()
    {
        if (button) button.onClick.Invoke();
        //do something
    }

    private void OnDestroy()
    {
        if (initialized)
        {
            RewiredPlayerID.OnValueChanged -= UpdateRewiredPlayer;
        }
    }
}
I have also disabled the button itself so that it isn't being pressed via a selectable system (not sure if this is totally necessary). I set the Continue Button in the inspector on the standard subtitle panels so that it adds the necessary callbacks. When I press the continue button, it only fires once onto the correct subtitle panel. I even removed the StandardUIContinueButtonFastForward for now as I debug.

I have noticed that if I am not in a player menu, and just in regular dialogue what happens is both conversations move forward no matter who presses continue. Obviously not desired but nothing fully breaks. The correct panel receives the input event, not both, but somehow both conversations jump forward. As soon as I make it to a menu panel then input generally breaks on one of the panels and only one player can move forward in the conversation.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Splitscreen Issues

Post by Tony Li »

Hi,

Would it be possible to send a reproduction project to tony (at) pixelcrushers.com? Alternatively, I can put together an example scene if you prefer.
splinedrew
Posts: 13
Joined: Tue Mar 15, 2022 8:53 pm

Re: Splitscreen Issues

Post by splinedrew »

That sounds good, I will prepare a simplified version to send your way. Thank you!
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Splitscreen Issues

Post by Tony Li »

Please include the steps I should follow to produce the issue, what I should see when it's working correctly, and what I'll currently see that needs fixing.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Splitscreen Issues

Post by Tony Li »

Hi,

Thanks for sending the repro project! The primary gotcha is that each conversation needs to use a separate dialogue UI, even if two conversations would be using different panels. I sent you an example that uses Override Dialogue UI to use separate dialogue UIs.

The other issue is related to setting EventSystem.current. I included a script for that.
Post Reply