I’m adding a kill animation to my enemy, where the player is unable to move and the enemy beats him to death. The problem is that the enemy slides towards the player during the animation as an effect of running towards him before attack, making it look completely broken. So I need to make sure he stays in the exact same place during the animation.
The enemy has a Rigidbody, a few trigger colliders but no ordinary ones, and a Navmesh agent to make it chase the player. Is there a way to fix an object’s position through scripting? I haven’t found any solution by searching for it on Google.
Could you explain, how your player is moving towards the player? I guess, you are using the navmesh and the agent to automatically let your enemy run towards your player, right? So, if your animation starts, he will still move the player because of the agent. I guess, you could just disable the agent’s script, so he will stop moving towards him with enabled = false;
I’ve thought of this and therefore I’ve set the agent’s speed to 0 when playing the animation. The enemy doesn’t move constantly, but only slides a little, slowing down rather quickly. Therefore I think something, be it the agent, Rigidbody or something else, is taking a moment to stop. But I don’t know what, because the agent’s stopping distance is set to 0. I must be missing something.
if you’re not using the rigidbody to move the player you need to set it to “is Kinematic”