I have multiple states in an animator, and i need to change the layer default state under if conditions. How can i set a state as layer default state with script?
Afaik you can’t. The question is: Why would you want to? The default state is the state the animator goes to when the component is initialized. Before that happened, the component doesn’t exist, so you cannot do anything with it. And after that happened, it’s too late, and the component already needed the default state.
You can probably just switch to any other state after initialization and never go to the default state again if you wish.