for instance,
I have a player triggers a conversation after onTrigger enter to a npc
then the conversation starts
at certain dialogue entry point, I want to play another gameobject (not player, not npc) animation
I need to set that gameobject's animator parameter at some point
what I'm doing right now add some variable field in that dialogue entry, then write a script to find those variables and do the animator.setxxx with those conditions
is there any efficient way without writing additional scripts, use sequences to set animator state? tks
set animator parameter in a dialogue entry
Re: set animator parameter in a dialogue entry
Hi,
Yes, this is exactly what sequences are for. Let's say the GameObject is named Bomb, and you want to set its Explode trigger parameter. Set the dialogue entry node's Sequence field to:
The first line plays the Dialogue Manager's Default Sequence. The second line adds a command to set the Explode trigger on the GameObject named Bomb.
More info: Cutscene Sequences, Tutorials
Yes, this is exactly what sequences are for. Let's say the GameObject is named Bomb, and you want to set its Explode trigger parameter. Set the dialogue entry node's Sequence field to:
Code: Select all
{{default}};
AnimatorTrigger(Explode, Bomb)
More info: Cutscene Sequences, Tutorials
Re: set animator parameter in a dialogue entry
nice, so if I want to set a gameobject in the scene (has animator controller)
let's say the parameter is a bool, so I can add something like the following in the sequence from any dialogue entry inside of a conversation right?
AnimatorBool(walking, true, myobject_name)
one question, for the game object name, if that game object contains space, does it matter?
let's say the parameter is a bool, so I can add something like the following in the sequence from any dialogue entry inside of a conversation right?
AnimatorBool(walking, true, myobject_name)
one question, for the game object name, if that game object contains space, does it matter?
Re: set animator parameter in a dialogue entry
Yes, that's all correct. GameObject names can contain spaces.
Re: set animator parameter in a dialogue entry
sorry Tony, just missed an important issue, what if I have two game objects that have same name? tks
Re: set animator parameter in a dialogue entry
In that case you'll need to name one differently. Or, if one of them is the dialogue entry node's speaker or listener, you can use 'speaker' or 'listener' instead of the GameObject name.
Alternatively, you can use scene events.
Alternatively, you can use scene events.
Re: set animator parameter in a dialogue entry
tks Tony, sure I can name it differently
speaking of the "speaker" or "listener", does "speaker" means "actor" and "listener" means "Conversant"? otherwise how or where do I set them as "listener" or "speaker"
as it for scen events, that was the first place I was look for but turns out UnityEvent doesn't not support animator parameter functions because it takes two parameters, or am I missing anything?
speaking of the "speaker" or "listener", does "speaker" means "actor" and "listener" means "Conversant"? otherwise how or where do I set them as "listener" or "speaker"
as it for scen events, that was the first place I was look for but turns out UnityEvent doesn't not support animator parameter functions because it takes two parameters, or am I missing anything?
Re: set animator parameter in a dialogue entry
'speaker' and 'listener' change with each dialogue entry node.
'speaker' is the GameObject associated with the node's Actor.
'listener' is the GameObject associated with the node's Conversant.
UnityEvents can call an Animator's Play() and SetTrigger() methods. If you use UnityEvents, you can use those methods.