How do you move the player towards a model and then play an animation?

I’m trying to create a door opening system, and I want to know the best way to go about doing something like this video.

It’s not obvious in the video, but when the player interacts with the door, if they are far away from it, they get moved towards the door so that the opening animation can play in the correct spot. I hope that makes sense

How would I go about implementing this? I’m trying to figure out how to:

A. move the player closer to the door so that the player animation isn’t offset

B. Figure out how to include player animations and the door animations in the same file, and then play them together. In other words, I only know how to animate the player but I want to animate the door WITH the player

Edit: this is what I’m working with

2 Likes

Ok. There are probably multiple ways to go about this, but I think this would be best.

First, determine how close they need to be to the door to interact with it.

Whenever they interact with the door: Disable their controls (set their movement speed to 0 and jump height to 0). Then, tween their rotation to face the door from their current rotation (some trigonometry needed). After that, calculate their total distance from the position the player should be when it plays the animation (more trigonometry needed). Then, based on how fast the player normally moves, calculate how long it should take them to walk to the open door position. Once you do that, tween their position to the door opening position and make it take as long as the time we calculated. (otherwise, they’ll move super fast when far away from the door or move super slow if they are right next to it.) Then, rotate them to face the door, and play the door opening animation.