Stopping player animation when entering conversation

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

Stopping player animation when entering conversation

Post by lostmushroom »

Hey, I'm using Dialogue System with Corgi and Spine, and I'm getting some issues with animation when entering conversations.

If I begin a conversation while the character is walking, it will continue to play the walk animation in place through the whole conversation. Is there a way to disable this or force the animation to switch to idle when you enter the conversation? (This is a Spine animation on a Corgi character, if it makes any difference).

Also for the future, I will probably want to trigger certain animations to play on both the PC and NPCs at certain points in conversations. I know there is an example of this in the Corgi/Dialogue System demo but does it work the same way with Spine animations?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stopping player animation when entering conversation

Post by Tony Li »

Hi,

If you're using a SkeletonMecanim component, see step 5 of Corgi Support - How To Set Up Scenes. Briefly, use a Dialogue System Trigger to set the player's animator parameters to make it stop.

If you're using SkeletonAnimation, you'll need to add a custom script that stops the animation in an OnConversationStart method.

To play animations during conversations, if you're using SkeletonMecanim then you can just use regular AnimatorPlay(), AnimatorTrigger(), etc., sequencer commands.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Stopping player animation when entering conversation

Post by lostmushroom »

Just tried to set it up as it is in the documentation. The behavior is still the same and I'm getting a couple of warnings.

- Game object with animator is inactive
- Animator is not playing an AnimatorController

Thanks for your help :)
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stopping player animation when entering conversation

Post by Tony Li »

If you temporarily set the Dialogue Manager's Debug Level to Info, when the AnimatorXXX() sequencer commands run they will report which GameObject they're looking for an Animator on. What GameObject do they report? At the time the sequencer commands run, Is the Animator component disabled on this GameObject?

Alternatively, you could remove that Dialogue System Trigger and add a Dialogue System Events component instead. Configure OnConversationStart() to call the player's CharacterPause.PauseCharacter method. Configure OnConversationEnd() to call CharacterPause.UnPauseCharacter.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Stopping player animation when entering conversation

Post by lostmushroom »

I get this message:

Dialogue System: Sequencer: AnimatorFloat (Speed, 0, Player)
UnityEngine.Debug:Log (Object)

The animator on the player prefab doesn't seem to be disabled at any time.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stopping player animation when entering conversation

Post by Tony Li »

Can you send a reproduction scene to tony (at) pixelcrushers.com?

What if you call Pause and UnPause instead as suggested above?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stopping player animation when entering conversation

Post by Tony Li »

Thanks for sending the reproduction files. I'm copying some of my email reply into this post in case others have a similar question in the future.

On the NPC's ConversationZone GameObject, inspect the Dialogue System Trigger and remove the Play Sequence action. (Copy the sequence to the clipboard first.)

Then open your Player prefab.
- Add a Dialogue System Trigger set to OnConversationStart.
- Select Add Action > Play Sequence.
- Assign the player's SpineAnimation child GameObject to the Sequence Speaker field.
- Paste in the sequence.

The Dialogue System Trigger on the NPC was pointing to the Player prefab. At runtime, Corgi instantiates a copy of the prefab into the scene. You want to control the animation state of this scene instance. However, Jerick's Dialogue System Trigger still points to the prefab. When it runs its Play Sequence action, it points to the prefab instead of the instance in the scene, so the instance is never notified to stop its animation.

By moving the Play Sequence action to the player, it's guaranteed to run on the instance.

Also, it's important to assign the SpineAnimation child GameObject because this has the Animator that Corgi controls to make the player look like it's walking.
Post Reply