Input doesn't work correctly across scenes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Input doesn't work correctly across scenes

Post by lostmushroom »

I have a couple of problems with using a keyboard or controller. Using X or Space to choose dialogue options works perfectly in one scene, but in others, it doesn't seem to work and I have to switch to using the mouse to click on options. Is there something I might have missed in setting this up?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Input doesn't work correctly across scenes

Post by Tony Li »

Inspect the Dialogue Manager's Input Device Manager component. Tick Always Auto Focus.

If the Input Device Manager detects that the player has moved or clicked the mouse, it switches the Mouse mode, in which it doesn't auto-focus UI elements ("select" in Unity UI parlance) unless Always Auto Focus is ticked.

If you want to prevent the player from being able to switch to Mouse mode, untick Detect Mouse Control. If you also want to prevent the Input Device Manager from hiding and locking the mouse cursor, untick Control Cursor State.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Input doesn't work correctly across scenes

Post by lostmushroom »

Thanks - input works correctly now :D

I have another small issue, not sure if it's related but it might be an input thing. I have the following sequence in a Dialogue System Trigger on my player character, to stop it from animating during a conversation:

AnimatorFloat(Speed,0)@0.1;
AnimatorFloat(xSpeed,0)@0.1;
AnimatorFloat(ySpeed,0)@0.1;
AnimatorBool(Walking,false)@0.1;
AnimatorBool(Running,false)@0.1;
AnimatorPlay(Idle)@0.1

This works correctly with most conversations, but there are a couple that seem to ignore it, meaning that character loops its jump animation during conversation. They are all using the same conversation zone prefab so I'm not sure what's up with it.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Input doesn't work correctly across scenes

Post by Tony Li »

Is it possible that the player isn't assigned to those conversations, so it's not receiving the message to idle?

More info: Character GameObject Assignments

You can temporarily set the Dialogue Manager's Debug Level to Info and look for the "Starting conversation" line in the Console. Make sure it reports the correct GameObject for the player.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Input doesn't work correctly across scenes

Post by lostmushroom »

It looks like the player is assigned as the Conversation Actor when it begins the conversation. I also get a warning:

Animator.GotoState: State could not be found
Unity.Engine.Animator: Play (String, Int32)

However, this shows up on all conversations including the ones that work, so I guess it's not that.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Input doesn't work correctly across scenes

Post by Tony Li »

Does the problem consistently happen with the same conversations?

What animator state do you think "Animator.GotoState: State could not be found" refers to? I doubt it's the player, since Idle works in other conversations. Maybe it's a state on an NPC? If you click on the message in the Console window, does the state trace reveal any more detail?

(Feel free to send me a copy of your project with reproduction steps if you're stuck or have other things you need to get to before the end of the jam.)
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Input doesn't work correctly across scenes

Post by lostmushroom »

It doesn't seem to happen consistently. I can't figure out the exact steps for reproducing the issue, otherwise I'd send a copy. The only thing I noticed is that it only seems to happen after you've changed scene at least once.

I'll keep trying to figure it out :D
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Input doesn't work correctly across scenes

Post by Tony Li »

It sounds like maybe there's an assignment between a GameObject that's marked Dont Destroy On Load (such as the Dialogue Manager) and a GameObject that's not marked. When you change scenes, the assignment will be lost.
Post Reply