Mecanim transitions with and without parameters

This is a similar problem to what this poster was experiencing;

http://forum.unity3d.com/threads/154187-Mecanim-Transitions

Essentially, I have a transition that I want to delay to give the player more time to give input that may alter the transition, as such;

But when I come back to the transition, Unity resets it for me;

Notice that there is an eye-like icon to the left and that seems to appear when there is a condition for the transition. If there is no condition, it changes to an arrow and it in fact lets play the transition later on in the state, as such;

We need the conditions for the transition and we would also like to delay the transition towards the tail end of the state. This will allow the player more time to input commands that would alter the state. Is there any way to accomplish this?

Hi Joseph.

When you have no exit time in the transition, the transion is taken as soon as all their conditions are met. The best we can do in the previewwer (and timelines) is to allow you to see what will happen if conditions are met at a given time!

Henre the “eye” icon: its only there for verifying what will happen when transition is started at different time. You can still change the lenght of the transition, and also offset the time that the next State will start.

That being said, we want to make it more intuitive in the next version(s). Ideas are welcome!

So for what you would like to do, I would say that you would have to do that externally of Mecanim, in your AI/Player logic.

Well, one of the things I was considering is having an exit state, that way we can force the whole animation to play. From what you’re saying, as soon as the conditions for the next state are met, it’s going to transition to that next state, therefore, it’s not going to play the whole state if the user were to provide input at the beginning?

If this is the case, then it would make sense to have a short end-state for each punch so that the player has time to input and the condition is only checked after the state has finished playing.

Please correct me if I’m wrong, but if I were to code this in the Player logic, it would go as follows;

Currently, I have two transitions after Punch1 has finished playing; back to idle and to Punch2. I think the reason I’m messing up is that the back to idle transition also takes a condition where “isAttacking” equals false. If I understand what you’re saying correctly, I should instead give it an exit time, detect through code when the state is about to transition, and as soon as it’s ready, check for player input, and only then should I update with animator.SetBool() or other. The code I’m using;

private AnimatorStateInfo currentInfo;
private AnimatorStateInfo nextInfo;

void Update() {
        nextInfo = animator.GetCurrentAnimatorStateInfo(0);
        if (currentInfo.nameHash != nextInfo.nameHash) {
                currentInfo = nextInfo;
                //State Changed, update animator with SetBool("isAttacking", true); and SetBool("isPunch", isPunching);
        }
}

I think this might be a better way of doing it, you’re right. The other way (having the animator create end-states would be more work and wont necessarily give better results.

By the way, a hub state in Mecanim would be really cool. It may be that as I use it I learn that I don’t need it, but some form of an empty state I can use just to make connections and check conditions would be really awesome. That way it’s a 1 frame deal and I don’t have to make any fake transition animations for that to happen.