start an animation without state name or trigger

Hi all
I would like to start the first animation connected to start state without name or trigger parameter.
I have to define the same trigger parameter for all animations to start from start state?
thx in advance

I dont get your point!!

it works already like you want, the default state will be triggered and played automatically

yes but I dont want only one time! I have several states, so it transits to other states and when I activate the gameobject, it is not started from the first state

Wow I still don’t get it.
So you have a set of states, IE: FirstState, SecondState, ThirdState.
you have an gameObject that plays an animation FirstState, Then you active the gameObject. but wait if it wasn’t active how did it play the FirstState? But if you did activate the gameObject it’s not playing the FirstState. So what is it animation is it playing? no animation? the SecondState or ThirdState?

wow wow wowwwww!!!
yes I have several animations I said before!!!
only one time (for the first time when the game object is activated) it is started from the first animation(s1)
start-> s1->s2->…
but for the second,third etc time when my gameobject is activated, it is in the last animation
I can use animator.play
but I don’t want to use state name , I want when the gameobject is activated, my animation is started from the first state without any conditions (like name,etc)
my question is so clear!!!

1 Like

you can have only one state that is connect to start node. I want to play this animation when I want without statename or trigger activation

it sounds like you need to look into OnEnable()

it’s kind of like Start() except it runs when the gameObject is activated

as far as the playing the first animation every time.
You may have to provide some of your code to get a better answer on this. I don’t know how you are currently switching between the animation.
Do you have the list of animation is some kind of Array or List<>.

my problem is not OnEnable or Start!!!
“you can have only one state that is connect to start node. I want to play this animation when I want without statename or trigger activation”

from what you said you cant do that!!

you can play animation, by activating the state, and there is 2 ways to do that calling Play(“statename”) or by Transition (trigger,bool, or any other condition)

if you can give more details about what you are trying to acheive, probably we could help!!!

So let me try again to understand.
you have a gameObject, it’s currently active = false.
then if activate = true, for the first time, play animation s1, then activate = false
then if activate = true, for the second time, play animation s2, then activate = false
then if activate = true, for the third time, play animation s3, then activate = false
then if activate = true, for the forth time, play animation s4, then activate = false

is this what you’re after?

yes but I always want to play the first state s1 when I activate the game object.
startnode->s1->s2->s3
I said I can write animator.play(“s1_state”,0,0);
but if I have 1000 animators with different first state name(s1_state for animator1,a1_state for animator2,b1_state for animator3) I need to define a string variable (state name) and change it for every animator!
but unity should have a simple function that can execute from the first without anything

can you tell me how you are determining witch animation is the first animation? if you have 1000 animation and each gameOject plays a different first animation. you have to specify that same where. you can create a public animation variable to set the first animation. you could create a relational dictionary to link statename with first animation

good luck with this. I’m all out of ideas and questions. you’re not giving enough info to help.

Ok, I dont really know how is your statemachine!!

but in any case, what if you create a transition from anystate to your first state, which can be activated always with same parameter name, so in that case for all 1000 animator you call settrigger(sameparamName);

and be sure that you reset all parameters you may have in the animator!!

yes I thought it has a simple function to reset!
Thanks. I create a trigger parameter for all animators (same name)