- Home /
2D Animation overriding object movement
I'm working in Unity 2D. I'm trying to make a cutscene system, where when the playable character object enters a trigger, player input is disabled and an animation moves the player object's position instead.
Trouble is, when the player character object's Animator component is active, player input no longer moves the object, whether it's touching the cutscene trigger or not. It seems like the Animator component is causing the object to ignore all other forces.
This is the code I have playing the animations. When the player object enters the trigger, it passes an array of Animators, and an array of strings of the animation names, to this script. In this case, "currentEvent.animators[i]" would be the player object's animator component, and "currentEvent.animationNames[i]" is the name of the animation in which the player moves. I know for sure the script is receiving both of these properly.
if (currentEvent.animationNames.Length > 0 && currentEvent.animators.Length > 0)
{
for (int i = 0; i < currentEvent.animators.Length; i++)
{
if(currentEvent.animators[i] != null)
{
currentEvent.animators[i].Rebind();
currentEvent.animators[i].Play(currentEvent.animationNames[i]);
if (!animators.Contains(currentEvent.animators[i]))
animators.Enqueue(currentEvent.animators[i]);
}
}
}
Also relevant, the animator component is on the player object itself, I'm not doing anything with children. "Apply Root Motion" is checked on the animator. Any help is appreciated!
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
How do I construct my animation state machine this way? 0 Answers
Preview overridden and ovverriding animation at once 0 Answers
Dynamic animator(2D) array Unity4.3 0 Answers
Multiple Animation Controllers 1 Answer