I have a character running using the root motion from an animation clip (“run”) in the timeline. What I need is a way for the character to follow the terrain surface while it is running. The problem though is that when I try to animate the vertical “Y” position of the character to position it accordingly to the height of the terrain surface, then the character doesn’t move forward any longer.
I tried using character controller with/without rigidbody, thinking that it would use the gravity, to follow the terrain irregularities but this doesn’t work either.
In the animation system, each channel of the position cannot be animated independently.
You can try animating parenting the character to another GameObject, and animating the y component on the parent gameObject to make the child follow the terrain.
When I do that, parenting the character to an object and trying to animate the y component of the object, the character and the object are both in totally different places, even when I reset both transforms and position both objects at 0,0,0 world position before parenting them.
I believe that this kind of situation should be common enough to deserve some sort of solution included in the timeline tool?
If there is any other suggestion please don’t hesitate to let me know, because timeline becomes kind of unusable if I have to spend so many days trying to hack a solution for such a common problem(which I haven’t found yet), if it is not possible to translate a character following a simple terrain height, how is the timeline suppose to seriously help in creating this common kind of cutscenes?
This is a case for a custom Timeline track, isn’t it? A track that will apply animation and root motion movement when applying Y position correction based on Raycast. @seant_unity Are source codes for default timeline tracks avaible somewhere? I also could use a custom animation track.
@strongbox3d - I’m not sure I understand where the parenting problem lies. Without timeline enabled, parent your character to an object that has default transforms. At that point, make sure the behaviour of your timeline/game has not changed. Then go into timeline and animate the y position of the parent.
As for it being a default part of timeline, it’s not a bad suggestion at all. The animation team is working on a couple improvements that may allow for it in the not too distant future.
@Xaon - the source code is not downloadable for animation and audio tracks.
Custom animation tracks are possible in 2017.3. We made a couple minor fixes to allow it, but it can be a bit tricky to replicate the timeline tracks, as there are some internal playables custom written for timeline by the animation team that are not in the public API.
I created an empty object with a timeline on it.
I created an animation track on the timeline and added my character to it.
I used animation clips for the forward and rotation movements of the character to go from point A to point B.
At this point I notice that although the character had a character controller the character was not following the terrain height with the gravity from the character controller.
I added a rigidbody to the character together with the character controller and still the character was hovering when running through the lower parts of the terrain, so not gravity still.
I decided to try animating the y component of the character but this broke the character’s movement forward right away.
So I decided to try parenting the character to a new object in order to isolate the y movement by moving the y component of the new object’s transform instead of animating the actual character directly thinking that this would work, but it didn’t. As soon as I parented the character to the new object they both appeared in very different locations.
When parenting the character to the new object, I did after resetting the transform of both the character and the new object and position them at (0, 0, 0) so to avoid any problems related to parenting, and still didn’t work, both appeared again in very different positions.
After all of these I decided to ask here, and here we are.
Just for clarity this is what I need:
I need a way to animated the character’s transform y component so it matches the different heights of the terrain, while the character is moving/rotating using the root motion of the animation clips… or for gravity to work as the character move and rotate using the root motion of the animation clips.
I would be really interested to know if someone managed to do this efficiently
Right now I am getting around it by animating a character using a controller and recording it’s animation using the script “RecordTransformHierarchy”.
Then, I have the problem that the script “RecordTransformHierarchy” only record my animation under a group, meaning that I have now my character that has Mocap, having it’s normal character root in the hierarchy window as an animation track in Timeline + a duplicate of that character that has this custom recorded Animation but under a new gameobject acting as a group.
I am mainly using Unity, Timeline and Cinemachine to do Cinematics tests.