Hi my idle animation is not working as intended. When the character is idling, it slowly moves out of place. I checked that the movement is not caused by the script.
It seems to be related to physics because when I turned on kinematics and turned off the character's collider the idle animation did not cause the character to drift. I scoured the web for similar problems, and can only think that my problem has to do with movement caused by the animation itself.
When I imported the animation from Blender I checked 'Baked Animation'. In Unity I also set 'Root Node' to None for the imported animations. From what I read, setting root node makes the animation interact with its surroundings (and move) whereas baked means the animation is purely visual. However, none of this solves the problem of the drifting idle animation. I am running out of ideas and would really appreciate your help.
I could manually freeze the position via script, but this seems like a workaround. Interestingly, when I first enter game view and the idle animation plays there is no drifting. However, after exiting a walking animation and playing the idle animation again I see the drifting behavior.
Looks like you just need to uncheck 'Apply root motion' in animation import settings (in the inspector when you clicked on animtion file).
Root motion is the main reason why a 3d model moves away from its pivot without the help of a script. uncheck it from the import settings.
Related
In my Unity 3D project I've added an animated body as a child to the Player object. The player moves as is should, with the right animations displaying for each key. The problem however is that the transform of the child changes when I enter game mode, meaning the character is walking above the ground. In scene mode it's relative to it's parent, it's grounded, but when I switch to game mode the character suddenly changes it's y-axis transform. I also checked the inspector for this object, it's y-axis changes.
I tried disabling the movement script, to check if this could have anything to do with it, but nothing changes. The transform still changes. I'm new to this problem, and every thread I've found on the topic hasn't helped much. Does anyone know what might cause this?
The hierarchy. mixamorig:Hips is the one changing it's transform. The animations and animation skin I'm using is from Mixamo.
DESCRIPTION OF THE PROBLEM
I have a character with a throwing animation that has a Rigidbody with "Use gravity" checked. At the moment of the throw, in the middle of the animation, the character moves up a from the ground.
OBSERVATIONS ABOUT THE PROBLEM
This upward movement does not seem to be present in the animation itself when viewed in Unity's animation inspector, nor is it present in Mixamo, which is where I got it from.
The character never comes down if I DO NOT check the option below and keeps climbing up each time the animation is played.
If I DO check it, then the character STILL goes up but immediately comes down once the animation is finished.
If I check "Freeze position (Y)" as below:
The problem stops but other animations such as death animations stop working as the character floats after dying.
I don't think it's the collider because the character stays well up off the ground after the animation ends and keeps going up more and more each time, staying far away from the ground.
The problem persists with "Apply root motion" unchecked in the Animator.
WHAT I HAVE TRIED
Disabling all scripts, removing the animation event that was present and fiddling with all of the settings that I mentioned here, to no avail.
QUESTIONS
1) Why could this be happening? How could I find the source of this movement given that I don't see it in Unity's animation inspector/Mixamo?
2) Is there a better fix than creating a StateMachineBehaviour script with OnStateEnter and turning on the Y constraint there and turning it off in OnStateExit?
I had the same problem as you.
In my case, the problem came from the definition of the NavMesh from a Plane. For some unknown reason, Unity created the NavMesh plane with a little elevation. Finally, I changed the plane to a cube and the navmesh succeeded, so the agents move well on zero height, as expected.
After many hours reviewing the animations and the different options, the problem was in the generation of the NavMesh.
Hope this can help you.
I have an issue with the current build and run operation on a project I'm making, where the default animation of a "scene" animator wont play, while in the editor in the same build, it does play.
This question that has a related title doesnt apply for my issue.
Unity Default Animation Not Playing
Moreover, just after I check play on the editor to check if everything works properly, I press ctrl+b to build and run, and in-game this default animation wont play, for no apparent reason.
Everything is set properly, , the speed of the animation, the animator, etc; everything works well in the editor and inside the editor's game window, even the game's sounds run in the background. But for a reason I can't seem to find, it will not play in the build. I'm not affecting anything else than a image component to make this "scene"
animation.
Detail of the animation issue: The animation is just a sliding diagonally-rotated black image, occupying all the game screen, that gradually moves to the right until it cant be seen in the screen. For some reason, this is not playing, making the screen be pitch black.
Any ideas will help, the game is an exam.
Problem: I was using an animator override controller, in version 2019.2.17f1.
Looks like the animation override controller had unsolved bugs for that version that are not visible in the editor; or something may have got set incorrectly, despite my repeated checks on this simple animator window.
Solution: I attempted to switch back to the normal animator component just to test, and everything works perfectly as intended; the animation plays.
Any comments/critiques regarding the problem/solution are very much welcome
I'm currently just trying to learn to use the animator within Unity, I'm very in-exp at animation and don't understand it even in the editor as I focus on programming/scripting.
I have an animation and the states for the animations as-well as the conditions all working perfectly however the animation check for the next state is way to slow. I've tried changing the speed of the actual state but it speeds the animation up and makes it look like my character is walking insanely fast.
I've tried messing around with the frames, making them over a longer time period and making the speed of the state faster however it seems to counter act each other, when I make it longer frames the pace of the animation is slow and then when I make the speed of the state go quicker it just makes the frames tick faster making the animation faster.
What I believe is happening is that the check for the next state of animation is happening once the full animation has been played. However what I need is the check to be happening constantly (as if frame by frame of the unity game not the animation).
Any advice would be great, I've tried using youtube to solve this before coming here however most people are creating a platformer game where as I'm trying to aim for a top down 2d, all directional character movement instead of the linear x axis character movement., and outside libraries.
I deeply apologise for my inability to find a suitable source. I have literally just came across an article online that came across a simple solution.
here:https://answers.unity.com/questions/221601/slow-animation-response.html
basically if you can't be bothered to click the link and you are having the same problem,
find exit-time by clicking the transition and then in the inspector and untick it.
Sorry.
The problem:
I have a character model with a Nav Mesh Agent component. It moves perfectly well to any destination I tell it to move (using the NavMeshAgent.destination property).
But this suddenly fails as soon as I use an animation controller I downloaded from the store. The character won't run to it's destination; instead, it will endlessly run around it in circles.
I'm not sure why this happens, but I suppose the running animation somehow cripples the character's ability to turn. The Inspector, in the import setting of the relevant .fbx file shows: Average Angular Y Speed: 0.0 deg/s.
What I really, really fail to understand is why this keeps happening even though I have explicitely set NavMeshAgent.updatePosition and NavMeshAgent.updateRotation properties to true. The way I understand the documentation, this should make the character move as the Nav Mesh Agent wants it to move, and not as anything else (animations included) wants it to move?
How should I fix this problem? How should I force the animation not to meddle in the movement?
Do all your animation in place and use code to do the movement and you can uncheck root motion and use state machine values to get a better movement or use root motion and let mecanim`s retarget engine do the blending so go see for yourself what gets you better result , so I guess your problem is that your animation are not in place.
First: one of the biggest plus of Unity is its mecanim. Disabling root motion is negating a big advantage.
Second: the reason your character is running around probably is because the animator and the navmesh agent are issuing conflicting orders. Use updatePosition to false and updateRotation to true. Hence, the animator controls how fast you move and the navmesh agent controls the angular speed. Other posible cause is that your destination is unreachable. Check the Y component of the vectors and insure they are coplanar.