Setting animated objects transform to current position

I've just started looking into timeline and cinemachine and I'm very impressed. I want to start by creating some in-game animation sequences. I've created a simple sequence and it works fine - the player moves into a collider which then triggers a timeline sequence, the sequence performs some animations on the player.

The problem I have is that the animation uses the transform positions of the player object from when I originally made the animation, so when the player moves about and goes into the collider, the player then teleports to the fixed animation position. What I want is for the animation to use the current player position which could be anything and not the fixed positions in the animation sequence. Would I need to do this using a C# script? thanks!

2 Likes

On the animation track, you can change the Offset Mode to Use Scene Offsets. That will make the track play relative to the current position, as opposed to a fixed location.

6 Likes

Thanks very much

I'm having trouble with this as the animation I have chosen seems to rotate the main character 90* along the Y (up) axis. If I try to rotate the character's transform, the animation overrides this. If I have animation that is created, say, at origin and looking down the z axis, but the character is arbitrarily rotated in the scene, how do I get the animation to play, not only from the character's correct position in the scene, using scene offsets, but the rotation as well?

The offsets apply both transform and rotation. They should both be played relative to the current scene position when using Scene Offsets. If you don't want the rotation to be relative to the scene, you will have to reset just the rotation prior to playing the timeline.

Odd.

Here’s the sequence of events:

Original Position:

Original Transform:
4337986--391540--OriginalTransform.png

Position on Play:

Transform on Play:
4337986--391546--TransformOnPlay.png

(Due to image limit, this continues!)

Reset the transform (while the playhead is IN the animation):
4337989--391555--ResetPose.png

And check the Transform:
4337989--391558--ResetTransform.png

Advance one frame and the animation takes over again:
4337989--391552--PositionResturnsOnContinue.png

And the transform:
4337989--391549--PlayAfterCorrectionTransform.png

Now, this Rotation value seems INHERENT in the animation. It seems that the animation is facing 90* to the right and even though my model is facing down the Z-Axis the animation is forcing it to face down the X-Axis.

I've tried a few things like: Trimming the head of the animation, just in case there was a frame of the character facing forward and then the next frame was facing right, but even with the animation trimmed and the character adjusted to face down the Z, as soon as I move the playhead, the character faces down the X.

:-/

Just to make sure, here is the setting:
4338010--391561--3facef96133e24f7e9d34d1e4d0dff7b.png

If I set the Track Offsets to Transform Offsets; the animation behaves exactly the same (facing 90* out), just in a different location.

Unchecking "Apply Root Motion" from the animator does nothing either...

I'm baffled.

The clip itself also has offsets, try setting it's offsets to the inverse of the initial rotation. (e.g. 0, -83, 0)

This?
4339762--391804--8eea00cb65c5f9e2a9bc0a525a3c801b.png

Yeah, I found that last night.

I put in -90 so remove the +90 orientation. This solved the immediate problem, but then it means that I have to manually remove that value from the following clip when I use "Match Offset to Previous Clip"; but it is a work around.

Thanks for all the help!

Hi @seant_unity is there an updated documentation or video tutorial to use offsets to control the object's position? I am having really tough time figuring out what to use - Tranform Offset or Scene Offset!!

Here is what I am trying to achieve :
I am trying to create a Cutscene where my character starts at a particular position, then the Cinemachine Cam kicks to go around the map a bit and finally end at a fix position. As this point, I want my character to appear at the new camera location (as if he walked all the way up here while the camera was panning around the map). But this is not working! How do I achieve this??!

how 4 year of timeline and we are at the same way ?

1 Like

Where is this field in Unity 2019? I've been spending hours trying to get some floating text to the right position and I'm pretty sure this is what the blocker is, if someone could tell me where to find this field that would be great.

The clip offset only shows up if the animation is animating the root transform. It is meant to offset the animation position, and doesn't apply otherwise.

Instead, you can create an override track and keyframe the position/rotation you want.

Is there a video that demonstrates this process? I am not able to get this to work! :frowning:

Same problem here. I am triggering a timeline using a collider trigger. I'm trying to get the timeline animations to start where they have been moved to in the scene. Are there any tutorials on this?

1 Like

Sorry, I missed the earlier reply...

Right click on the animation track, select Add Override Track. Move the clips to the override track.
On the main track, hit the record button, then move the object where it should be in the scene or (0,0,0) if it should be set at runtime.

On the main track, you should be able to then change the TrackOffsets to Apply Scene Offsets, which will have the timeline start at the current scene position.

2 Likes

Is there a way you can make your object move to the starting position of the cutscene from your current position by Timeline? The character somewhat warps, and if I use Apply Scene Offsets, sometimes the movement won't match the environment.

I assume you mean you want it to walk or similar to the starting position for the Timeline? I think you would have to do that yourself before starting the Timeline playing.

I once made the animation move a “target” object and so made the character run/walk towards the target (speed was based on distance to the target), so I guess you could use that trick at the start of the timeline, but overall it was painful as scrubbing the timeline in the editor moved the target, not the character, so it would run all around the place as you scrubbed. It ended up more annoying than useful.

Just diactive the boolean "Apply root motion" in your animator for some people that have this issue.

1 Like