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.
Related
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.
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.
I am trying to animate a warrior,
He has a special hit using the sword.
Jump, and hit..
During the animation he takes some steps to the front and after the animatiin is done.
It goes back to the idle state leaving the new position.
It annoys too much.
So what I am asking.
How to keep the new position and change the collider position to that new position?
How to keep the new position
Depends how you animate it. But essentially,
Make the animation not loop
Make it not transition to other unwanted animations.
Have the next animation begin from the endpoint of the previous one.
and change the collider position to that new position?
The collider position will follow the position of whichever object it is located on. Also if they are animated. So if your collider is on a leg and you move the leg outward, the collider will follow that same animation.
Additional information
If you don't know how to make things work from here. It would be great to show the code you are using (if any) and how you make the character animate.
If it is with an animation controller, please display the transitions and animations of it in a screenshot.
Always try to provide relevant scripts and screenshots when asking questions.
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.
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