Sequence of animations with AnimatorPlay()
- Pendergast
- Posts: 38
- Joined: Sun Oct 18, 2020 1:48 pm
Sequence of animations with AnimatorPlay()
Hi !
So, i am trying to play multiple animations with the sequencer ; i tried the animation() command, it worked but it messed with my animations. Is there any way to use AnimatorPlay() to do multiples animations like animation(), since AnimatorPlay() isn't messing with my animations ?
Exemple: With Animation(), i can do: Animation(Idle, Merevin, Talk, Idle). I want to do the same thing but with the Animator component !
Also, i tried to use the Audio() command, but it won't work (it says "Dialogue System: Sequencer: Audio() command: clip 'Taverne' could not be found or loaded." and i have an audio component on a gameobject, so i don't understand !)
Thank you in advance !
So, i am trying to play multiple animations with the sequencer ; i tried the animation() command, it worked but it messed with my animations. Is there any way to use AnimatorPlay() to do multiples animations like animation(), since AnimatorPlay() isn't messing with my animations ?
Exemple: With Animation(), i can do: Animation(Idle, Merevin, Talk, Idle). I want to do the same thing but with the Animator component !
Also, i tried to use the Audio() command, but it won't work (it says "Dialogue System: Sequencer: Audio() command: clip 'Taverne' could not be found or loaded." and i have an audio component on a gameobject, so i don't understand !)
Thank you in advance !
PENDERGAST / NyxNikita
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Re: Sequence of animations with AnimatorPlay()
Hi,
Here are two ways to do multiple animations with an Animator:
1. Create transitions from one animator state to the next:
If you use:
it will play Dance, then Bow, then Rest, then Idle.
2. Or use AnimatorPlayWait() with messages:
This solution has two advantages:
a. You don't have to create any transition arrows in your Animator Controller.
b. If the player skips ahead, the 'required' keyword guarantees that the animations will stop, and the character will return to the Idle state.
To use Audio() or AudioWait(), put your audio clips in a folder named Resources. Your project can have any number of Resources folders anywhere in the Assets folder structure.
If you have many audio clips, you can switch to Addressables or assetbundles later. You won't have to change any of your sequences to do that.
Here are two ways to do multiple animations with an Animator:
1. Create transitions from one animator state to the next:
If you use:
Code: Select all
AnimatorPlay(Dance)
2. Or use AnimatorPlayWait() with messages:
Code: Select all
AnimatorPlayWait(Dance)->Message(Danced);
AnimatorPlayWait(Bow)@Message(Danced)->Message(Bowed);
AnimatorPlayWait(Rest)@Message(Bowed)->Message(Rested);
required AnimatorPlayWait(Idle)->Message(Rested);
a. You don't have to create any transition arrows in your Animator Controller.
b. If the player skips ahead, the 'required' keyword guarantees that the animations will stop, and the character will return to the Idle state.
To use Audio() or AudioWait(), put your audio clips in a folder named Resources. Your project can have any number of Resources folders anywhere in the Assets folder structure.
If you have many audio clips, you can switch to Addressables or assetbundles later. You won't have to change any of your sequences to do that.
- Pendergast
- Posts: 38
- Joined: Sun Oct 18, 2020 1:48 pm
Re: Sequence of animations with AnimatorPlay()
Thank you !! It helped a lot !
The Audio() command works fine now, but i have trouble with stopping one audio to play another one. :/
The Audio() command works fine now, but i have trouble with stopping one audio to play another one. :/
PENDERGAST / NyxNikita
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Re: Sequence of animations with AnimatorPlay()
Try using AudioWait().
The Audio() command starts an audio clip and just lets it play without controlling it any further.
AudioWait() waits until the audio is done. If the subtitle is skipped before the audio is done -- for example, by clicking the continue button -- it will stop the audio.
The Audio() command starts an audio clip and just lets it play without controlling it any further.
AudioWait() waits until the audio is done. If the subtitle is skipped before the audio is done -- for example, by clicking the continue button -- it will stop the audio.
- Pendergast
- Posts: 38
- Joined: Sun Oct 18, 2020 1:48 pm
Re: Sequence of animations with AnimatorPlay()
Sadly, it doesn't work for what i want to do :/
It's for a visual novel game ; during a long time, i need an audio playing in loop in the background ; then change it when i tell it to do (change of ambiance/mood). AudioWait() stops right after the message where i used it is skipped
Also, another problem, i tried to use AudioWait() on the Start node and it broke the game at start ; when i use Audio(), it works :/
It's for a visual novel game ; during a long time, i need an audio playing in loop in the background ; then change it when i tell it to do (change of ambiance/mood). AudioWait() stops right after the message where i used it is skipped
Also, another problem, i tried to use AudioWait() on the Start node and it broke the game at start ; when i use Audio(), it works :/
PENDERGAST / NyxNikita
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Re: Sequence of animations with AnimatorPlay()
Hi,
Avoid putting anything in <START>. Leave it untouched, and add an empty node after <START> to play your sequencer commands. If you're using a continue button, you can include:
to make that node immediately move to the next one after running the sequence.
For the background music, you're correct -- use Audio(). Here is the manual reference: Audio() Sequencer Command
Set up a GameObject with your background music audio source. Tick the Loop checkbox. Then provide the GameObject name to Audio(). For example, if the GameObject is named "Music", and you want to play an audio clip song named "Relación":
This will find the GameObject named "Music" and use its audio source to play Relación.
Avoid putting anything in <START>. Leave it untouched, and add an empty node after <START> to play your sequencer commands. If you're using a continue button, you can include:
Code: Select all
Continue()
For the background music, you're correct -- use Audio(). Here is the manual reference: Audio() Sequencer Command
Set up a GameObject with your background music audio source. Tick the Loop checkbox. Then provide the GameObject name to Audio(). For example, if the GameObject is named "Music", and you want to play an audio clip song named "Relación":
Code: Select all
Audio(Relación, Music)
- Pendergast
- Posts: 38
- Joined: Sun Oct 18, 2020 1:48 pm
Re: Sequence of animations with AnimatorPlay()
Thanks for the advice about the <Start> node !
I tried to use the gameobject and audio() method ; but it seems i still can't switch audio with the sequencer. I had an error :
Dialogue System: Lua code 'return Audio(romance, Romance_01);
Continue()' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
(i used "Audio(romance, Romance_01);
Continue()" command)
I tried to use the gameobject and audio() method ; but it seems i still can't switch audio with the sequencer. I had an error :
Dialogue System: Lua code 'return Audio(romance, Romance_01);
Continue()' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
(i used "Audio(romance, Romance_01);
Continue()" command)
PENDERGAST / NyxNikita
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Re: Sequence of animations with AnimatorPlay()
Hi,
Put those commands in the Sequence field.
Put those commands in the Sequence field.
- Pendergast
- Posts: 38
- Joined: Sun Oct 18, 2020 1:48 pm
Re: Sequence of animations with AnimatorPlay()
Hi,
It's already in the Sequence field ; but restarting unity solved my problem !
And i still can't switch between multiple audio :/ And the AudioWait() isn't good for what i want to do. Do i have to code something myself to make what i want work ?
I saw that AudioStop() doesn't work with the Audio() command, is there another way ?
Thank you for your help, by the way !!
It's already in the Sequence field ; but restarting unity solved my problem !
And i still can't switch between multiple audio :/ And the AudioWait() isn't good for what i want to do. Do i have to code something myself to make what i want work ?
I saw that AudioStop() doesn't work with the Audio() command, is there another way ?
Thank you for your help, by the way !!
PENDERGAST / NyxNikita
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Artist & Writer
Caroline I. Letuppe
Instagram: https://instagram.com/nyxnikita
Site officiel: https://nyxnikita.com
Boutique: https://shop.nyxnikita.com
Tous mes liens: https://nyxnikita.carrd.co/
Re: Sequence of animations with AnimatorPlay()
Hi,
It looks like you have multiple GameObjects, each with its own Audio Source and audio clip. If that's correct, then use the SendMessage() sequencer command to tell it to play and stop:
(Note the two commas between Stop and Tavern_01. This is because Stop() does not need to receive a parameter.)
I misunderstood. I thought you had a single GameObject -- for example, named "Music" -- and you wanted to play all of the background music files on it. If you want to instead use a single GameObject like this, use Audio():
Later...
In this case, Tavern and romance should be in a folder named Resources.
It looks like you have multiple GameObjects, each with its own Audio Source and audio clip. If that's correct, then use the SendMessage() sequencer command to tell it to play and stop:
Code: Select all
SendMessage(Stop,,Tavern_01); // Call Stop() on GameObject Tavern_01.
SendMessage(Play,,Romance_01); // Call Play() on GameObject Romance_01.
I misunderstood. I thought you had a single GameObject -- for example, named "Music" -- and you wanted to play all of the background music files on it. If you want to instead use a single GameObject like this, use Audio():
Code: Select all
Audio(Taverne, Music); // Play Taverne on the Audio Source of the GameObject named Music.
Code: Select all
Audio(romance, Music); // Play romance on the Audio Source of the GameObject named Music.