- Home /
Camera returns to starting position after playing animation
Hey everyone,
So I have created an animation for my camera where is tracks forward towards my character and stops just infront on them. From here, I would like to take control of the camera with a script, from the cameras position after the animation. However, whenever the camera is finished playing the first animation, if I try to change to a new mechanim state it snaps back to its initial starting position.
I dont know the best way to go about this. Ideally, I would be able to control the camera back from its main monobehaviour script. But I have no way to tell when the animation is completed. And when I try to use a new state in mechanim, I have this issue. Any help would be appreaciated !
Answer by mlnczk · Jan 30, 2019 at 09:21 AM
You should use free asset DOTween. Its completly free and it replaces nicely animation in unity. Its very easy to use better optimised then creating Animator Controller animations etc. You will be able to set it very simply. You have commands over there that you can order object to move on whatever axis you want X distance in X time and when method finishes object should remain in that position. Check it out here : https://assetstore.unity.com/packages/tools/animation/dotween-hotween-v2-27676?aid=1101lSqC&utm_source=aff
Answer by hameed-ullah-jan · Jan 30, 2019 at 09:38 AM
while recording animation the position is also recording, whenever you play the animation after finishing the animation the camera will go back to its original position, you can clear this issue by making the camera child of a gameobject, attach animator to the parent object and while recording the animation do not change the position of the parent object only change the position of the camera (during recording state), once the recording is done, you can then change the position of the parent object through the script and do whatever you want with the parent object