Answer the question
In order to leave comments, you need to log in
Why, after reactivating the object, Animator began to work incorrectly?
Good afternoon friends. An animator hangs on the object and plays animations.
At a certain point, the object becomes inactive [gameObject.SetActive(false)], after which the object is activated again [gameObject.SetActive(True)] , but the animation does not play correctly, the animator stopped responding to changes in the parameters. A simple example: There are two animations, the movement of the character to the left and to the right, the parameter float LookDirection is responsible for this, when it is equal to 1, the animation moves to the right, -1 to the left. Initially, everything works correctly, but after reactivating the object, character animations stop changing, ignoring the parameter passing.
The parameter is passed like this:
_playerAnimator.SetFloat("LookDirection", _lookDirection);
If we request values via GetFloat("LookDirection"), we will see that the parameter is passed correctly, but switching between animations does not occur.
PS In many forums, this question has been repeatedly raised, but usually remained without a specific answer.
.
Answer the question
In order to leave comments, you need to log in
I suddenly found the answer. The solution is to save the animator settings after turning it off, I don't understand why it works, but it works. If someone understands how it works I will be glad to hear!
private void Start()
{
_playerAnimator.keepAnimatorControllerStateOnDisable = true;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question