Unity animation and movement trouble - c#

I'm using unity 3d v. 5.12 and for some reason, when I'm using an animation (made with unity, *.anim), any changes to a game Object's position are not applied. Please help. I'm totaly new to unity.

Before recording your animations, you should setup the properties of the animation by adding "transform position/transform rotation" in the animation window.
Once you're done recording your animation:
1 Click "Generate motion curves" on your animation object.
[Setup your object with its animation controller]
2 Set the animation controller in your object to "apply root motion" (tickbox)
Your object will now rotate/move independently of the objects rotation/position

If your animation is animating position component then any changes to position during animation is playing will not affect gameobject it will be controlled by animation. Same case applies to imported animations as well . And not only position if any other component is controlled by animation it will not be affected by code during animation is playing i.e scale rotation etc..

Here's the rule:
Any object that has a keyframe in the currently active animation cannot move (except for by the animator), it's FROZEN.
The rule stretches:
If there is a transition arrow from the currently active animation to another, that one is considered active and no objects with keyframes in that animation are allowed to be moved outside the animator either.
Summary:
If an object cannot move because of the animator, it is involved in the currently active animation or one of the transition animations PERIOD

Related

Unity 3d How to make the player to stay at the target position after the animation completes

Hello I have the Problem that the Animation Pos not stay. I need this for a Dodge(Combat) system. Root Motion Doesn't work!
.
You can make another state in animation and make your animation to go to that state. In script don't let player move when animation is in that state.
Return to idle state whenever you want to make things normal again.
Other way to do is use other animations libs (like leantween) and make a callback after animation ends.

Unity Animator problem with Anchored Position

I'm currently having a problem with Unity Animator and I haven't found a solution yet. I'm trying to animate the position of a UI object through its Anchored Position with Unity Animator. Even though I have the checkbox Apply Root Motion active, when the animation ends it returns to its original position, instead of maintaining the position that changed.
I activate the animations through Triggers in a Script, and all the Scripting logic works well. The expected behaviour would be like you can see in the gif, but moving through the connectors instead of turning back to its original cell.
I tried to make an Empty GO the parent and animate child, remake the animations, remake the animator, etc., but nothing worked so far and I don't know what to try next, and I could use some help.
Thanks for answering! I will answer anything necessary when asked!
Current State Gif:
Animator Screenshot:
I can't be sure why your apply root motion is not working as it should but you can fix this in another way.
You create 3 animations with the Anchor Position, one at the startpos, one for the transition from the first one to the end one, and the endpos.
Start animation and end animation should be looping while for the transitioning one you can uncheck the looping in the inspector of animation
In the animator set the startpos as default state and create a transition with the trigger to the moving animation. Then add a transition from this animation to the idle end position without a condition but just has exit time set of the time the last animation will play
In this way, it should all work fine and if you want to come back to the first position you can add another transition with a trigger to the start or whatever you prefer.

How to move a cube using an animation

I'm trying to make a cube in unity move using an animation I made in unity. When I press "W" the cube should animate to another position, but when the animation is finished it goes back to where the animation started. Also when I do the animation the animation starts at the position where the animation was created. I tried fixing this with applying root animation to my cube and checking the "Generating root motion curves at runtime" option in my animation inspector. But when I do that the cube won't move. Can I get some help with this issue.
This behavior is quite normal, once the animation stops. You have a couple of options.
If the animation is only about translation and rotation, then do it the straightforward way (without the animation) and by manipulating position and rotation
Create another animation that starts in the last frame of your moving animation and loop it (you have finite state machines in Unity for animations)
Cache the current position and rotation of your object, detect the
end of the animation and set the position and rotation to the last
cached values.

Unity 2D c# - How to save last animation position

I have player and his climb animation, so i want climb_end animation position save to game object player. I don't want return back to player position after last animation frame. Thanks
Make sure the animation is not set to loop (uncheck looping in the animation file).
Also, make sure "Has Exit Time" in the animation controller's climb_end animation state is unchecked. This might be causing the animation state to move onto another animation after it's finished running.

Unity 2D: animator single frame animations - instant transition

I'm using Animator to more easily control the state of a player sprite. Player sprite has only one frame for different animations (single image per different state), however - animator shows that it plays each frame 17ms.
So when player jumps I set animator parameter "InAir" to true, it should change sprite image instantly to InAir state, but for single frame previous state is visible (I believe it's because it takes 17ms for animator to transition) and in game there is noticeable flicker after jump.
How should I implement instant transition or is it possible to change the animation play time?
I had the same issue recently in Unity 5.3. I fixed it by clearing any Exit Time values for the transition. For some reason when the transition was created it was given some Exit Time default values which added extra time to the animation.
It can be seen by clicking on the transition and viewing the Inspector window.
My transition happened instantly when I disabled the Has Exit Time checkbox, and cleared the values under Settings.

Categories