Issue transitioning between anim states with both hasExitTime & using a transition condition

Hi,
I have a very basic animation setup using two states. The first state is an idle state called Idle, and the second state is Run. I transition from Idle to Run via a transition that has no exit time as it is triggered when a race starts by using animator.setTrigger to trigger condition “StartRace”. This works fine, however after I have transitioned to a state, when I then try and transition from that state to a different state using a transition that has both exit time and a trigger condition, it does not work. It will work if I disable exit time however that is not what I want.

I have attached a screenshot of the animator, and the two transitions. All triggers and strings are named correctly in code, and again, it works when hasExitTime on transition 2 (see attached pic) is disabled. When returning from the Run state to the Idle state, it also works if I remove the condition on the transition, but obviously that is also not want I want. It also will not work if the transition is disabled, but the exit time is adjusted to anything other than the default value.

I have also noticed that often when changing conditions in mechanim, even after saving the scene, or hitting “Play” on the Export Info object, Needle doesnt pick up the changes, and an Editor restart is needed. Is this a known issue? Needle version 3.22.1

import { Behaviour, Collision, ICollider, Animator } from “@needle-tools/engine”;
import { AnimatorStateTransitions } from “./Consts”;

export class RacerAnimatorChanger extends Behaviour {

private animator?: Animator | null = null;

awake(): void {
    this.animator = this.gameObject.getComponent(Animator);
}

onTriggerEnter(col: ICollider) {
    if (col.name == "AnimationTrigger") {
        this.animator?.setTrigger("Run");
    }
}

}

Original Post on Discord

by user 259070246382469121

Hi, thanks for the report. We’ll look into that.

When the changes are not picked up this would mean the AnimatorController data is not up to date - I haven’t seen this yet happen here but it would then perhaps be a Unity issue since we get all that information from the assigned controller. Which Unity Editor version are you using?

Do you think you could send a bugreport (via the Needle Engine menu item) with your project (the scene that has the animation/controller) or provide a reproduction in a new scene?

Hey Marcel,
Its Unity version 2022.3.12f1

I’ll check it in a separate project entirely to double check, and if that doesnt work Ill feed back here, and create the bug report.

by user 259070246382469121

Hey @marcel :cactus: I’ve just submitted the bug report. I checked it in a fresh project, and the same issue persists.

However I have just noticed that it does not work when the condition is a TRIGGER or BOOL but it does work if the condition is set to INT or FLOAT but I have only tested that after submitting the report. Would you like me to send an updated one?

by user 259070246382469121

Ok thank you. The on you sent now is with the trigger? I think that’s enough

It is yes. The one that was sent just uses a trigger parameter :+1:

by user 259070246382469121

Hi, thanks for the report. It should be fixed in the next version (trigger conditions didnt check if the transition could actually be made so the trigger was disabled too early)

Great to hear, thanks. I’ve yet to upgrade a project from one version of Needle to the next. Are there any known issues when upgrading?

by user 259070246382469121

Which version are you on? It’s worth checking out the changelogs in #:books:-releases if you are unsure but generally versions that update minor or patch versions should just work (that’s the 2nd and 3rd number in a version like 1.2.3)

Im on 3.22.1. I’ll take a look at upgrading when I see the fix in the release logs.

by user 259070246382469121

It’ll be included in the next version (probably released tomorrow)

Hi @nostalgicbear can you try again with 3.23.1 ?

@marcel :cactus: I can tomorrow mate, but cant today Im afraid. Should be able to feed back early in the morning

by user 259070246382469121

I’ve checked this and while the issue of animations only playing on the first element in the array is now fixed, the cycle offset and multipliers are back to having no effect again when the same animator is applied to multiple objects. So for example, if I had an animator called characterAnimator that had an IdleAnimation, and I had an idleOffset applied to the idle state - if I had 10 characters, and put that animator controller on 10 characters and applied a random offset - the animation no longer ceases to play on all the characters bar the first one like it did before, but the offsets dont have any effect. If instead of sharing one animator acroiss 10 characters I had characterAnimator1, characterAnimator2, characterAnimator3… etc - each character having their own - the offsets do take effect. So the issue is that when multiple objects share the same animator controller, offsets and multipliers dont take effect

by user 259070246382469121

Hi, i’m just trying the same here but can’t reproduce it so far. The cycle offset / parameter works as expected. Is the cycle offset perhaps set after the animation already started?

for example here the right row is using a random offset set from a script in start and the left row is not using any offset. They all use the same animatorcontroller
20231110-142608_Animator_Controller_Offsets_-_Google_Chrome-logo.mp4

Ah bloody hell yeah that was it sorry. Didnt realize that I had called ApplyOffset() after the animation had already started on that state. Thank you.

by user 259070246382469121

Ah yes, yeah it is applied when the state starts :slightly_smiling_face: