Move player by animation or script?
HI All, can somebody help me with question? I trying to create a mecanim system for character and now can't choose better case - how to move my player in space? By script changing transform, or by aminations with root motions? p.s. sorry for terrible english)
Answer by theANMATOR2b · Aug 11, 2016 at 02:11 PM
Blockquote
When developing games root motions for the avatar is never used , animations are only for moving the different skeleton parts in its place but the actual displacement in space is done using scripts. What will happen if root motion was used - when the animation will end and start again the avatar will go back to the same position where it started from.
Blockquote
Root motion is used quite often actually. In mecanim if the animations have root motion - on the animations tab check 'loop' to avoid the character snapping back to origin. If the animations do not have root motion - use code mentioned above - OR you can generate root motion if desired. Check the learning information under the animation section for guidance on generating root motion.
Okay, so, what way is better? Using root motion in mecanim, or move player by script?
There is no "better" way.
It's up to you how you want to proceed. As an artist - I prefer root motion. Working with programmers - they usually prefer to translate characters via code.
Benefit of using root motion - no foot sliding (reduced foot sliding), easier for animator to create animations that involve root motion, ins$$anonymous$$d of requiring root motion to be removed, easier for 2 character interactions (imo).
Benefit of using code - less user interfacing with mecanim, different/more control over transitions, ?? others - can use non-root motion without having to generate root motion.
Checking "loop" is exactly what i needed. Thank you very much !
Answer by jinincarnate · Aug 11, 2016 at 06:27 AM
When developing games root motions for the avatar is never used , animations are only for moving the different skeleton parts in its place but the actual displacement in space is done using scripts.
What will happen if root motion was used - when the animation will end and start again the avatar will go back to the same position where it started from.
So to move your avatar you can use different functions like transform.Translate , transform.Lerp,transform.Forward(check unity documentation for more details on these functions)
Answer by augivision · Apr 02, 2018 at 02:19 AM
Can any of you give an example of a C# script for:
Create a waypoint array from empty game objects.
Move object or player from current position to first waypoint at a certain speed.
Rotate towards or Look towards first waypoint and play "Walk" animation.
When the first waypoint is reached, play a "Laugh" animation, then walk towards the second waypoint at the end of the "Laugh" animation.
At the second waypoint, stop and play the "Cry" animation. Then proceed to waypoint 3.
Continue to add as many waypoints as you like in the array and attach an animation at each waypoint. The character will stop at the new waypoint, play the animation, then rotatetowards newer waypoint and start walking or running at a certain speed.
Your answer
Follow this Question
Related Questions
Problems with using the same Animator Controller on multiple objects. 0 Answers
How to make character animate as he's rotating? 2 Answers
Blend Trees with NavMeshAgent 0 Answers
Is there a possibility to reuse substate machines in other animator? 0 Answers
How do I add animations as "children" or "built-in" objects under an animation controller? 2 Answers