Problem with animation position update

Hi!

I have an animation that moves a guy. When the animation is done, I play a standing animation and change the position of the guy’s object to where the movement finished.

Apparently the new animation and the new position don’t both take place at the same time, and he disappears from where he should be for a frame or two when the transition happens.

I’ve tried setting the position one frame and the animation the next, or the other way around, with no luck.

Can this be done, or do I need to change how the guy is animated? If it’s the latter, how is this sort of thing done?

What’s going on is the guy moves under power of a script, then when he reaches a ladder, the animation takes over, then when he’s off the ladder, the script takes over again. I want the transition between the two not to be visible. I like having the animation move the guy, since it means his feet hit the rungs of the ladder correctly.

I think the problem you’re having is that you’re moving the player with a player controller (scripting, etc.) and then you are trying to change his position via animations from your 3D package. This is why you are having these issues.

I recommend for you not to use animations from your 3d package to change the position of the entire character in your scene/level. You need to design something much more robust for in-game character re-positioning. You 3d package should only concern itself with animations that supplement player aesthetic movements, like talking to another character, punching, etc. Unity via scripting, character controller, etc. should be in charge of your character’s position in the environment space.

Here is an example of how I would approach making a player walk up to a ladder, climb it, and then get to top/complete the ladder climb:

1- make 2 player triggers, waypoints, helpers, whatever you want to call them; one for the bottom of ladder and one for top; basically both ends of the ladder.

2- setup some code so when the player walks up to this trigger and hits the “climb ladder” button to initiate some function, this function can make the player controller get constrained to a rail type system where if the player hits the move forward button, player controller moves up the ladder at a set speed, but if player hits walk backwards button, player climbs or moves down; sideways movement should be constrained and not available while this function runs. When player reaches the top, another trigger can activate the end of the action, allow player to exit “ladder” mode and continue on, etc.

3- setup the animations in your 3d package; synchronize your animation to match with the ladder geometry you also make in the 3d package; this takes some careful planning and attention must be paid to scene scale, which should match with your Unity environment. This part basically takes care of itself, considering you did a good job when planning and writing your technical design document, etc.

4- make it all work in Unity; make the triggers/ladder endpoints work with the player controller movement, and add animation from the 3d package, which will complete the aesthetics part of the player action- done.

Keep in mind, this is just one way of engineering this feature for your game, there are probably 101 ways to go about this. I would recommend going to the drawing board and doing some planning and wireframes of this feature and narrow it down to a method you think will work best for your game. A properly engineered plan will make all the difference here, and in every aspect of game development. Good luck.

It would be much easier if I could just reposition the object to the end location of the animation when it’s done than have to update the object’s position during the animation via script. That way the animator has all the control over the motion of the character. Are you saying this is impossible in Unity? I’m a veteran coder, and he’s a veteran animator. After working at Ubisoft Montreal for 6 years, we have grown accustomed to animation-driven design, and it’s what seems to be the best idea here. This is why I hesitate to switch to stationary animation with script-control of the object’s motion.

Is there some sort of system where the animator can store the offset data over the course of the animation to update the object’s position with?

Well that’s just it (and I didnt say anything about impossible, please dont put words in my mouth please) Unity is a pretty empty canvas for games. Unity, unlike Unreal (which you probably worked with at Ubisoft), doesnt come with a complex character animation system. Its pretty much a clean slate, and anything more complex than what is covered by default in the docs, etc. will mean you will need to have your tools developers create from scratch any systems you need to meet the production needs of your game. So, no, by default Unity doesnt exactly include a pre-built system for what you need for your character animation/control needs, but you can always create the feature in-house for yourself. For example, with us, we create a lot of in-house features, tools, and systems for our game development; our guys are currently working on a custom solution for an in-game player store for a game we are currently developing, among other things. I agree your method would be best, in terms of looking good to the player (no sudden position jumping, etc.), but this is something your team will have to develop custom for your game.

If you look, you’ll see I asked if you were saying it was impossible, which is not putting the words in your mouth. :slight_smile: If there is a way to get the animation and the position to update at the same time, then I have it handled.

I’m sure there is a way to do it, it’s just about sitting down, doing some R&D, planning it out, etc. One thing I would look at doing is creating a completely custom character controller and not using the prefab one from the Unity standard assets, at least thats where I would get started.

Fixed. They do update on the same frame. There was another subtle bug in the code. Thanks for your help; sorry it turned out to be unrelated to the animation/repositioning issue.

That’s great, cool.