Pull GameObject toward collider/player


Currently, I am trying to create multi-hit aerial attacks similar to Smash Brothers. The problem with this is that the enemy will of course not move with the player once caught in the attack. Since this is all practice I don’t need it to be perfect. ** Simply put, I would like to find a way to have the Enemy stay with the player while being attacked (in other words, a way for the enemy to be “pulled” inside the attack collider)**. Of course parenting came to mind, however, having a child rigidbody with a parent rigidbody is apparently a mess.

I don’t have any example code (related specifically to this issue) as everything I’ve tried ended in failure. I’ve been trying things such as matching the enemy position/velocity or pulling the enemy to the player with AddForce, but frankly, it hasn’t worked out or I haven’t done it in the correct way.

I’m still new to Unity, so please tell me if anything else needs to be said/ more specific! Thank you in advance.

-One important thing is that since this is a multihit move, the collider turns off and on throughout the animation. Could this be a reason for the struggle as well?

I somewhat figured it out!
Basically, once I hit the enemy I have the enemy set their rigidbody to kinematic and make it the child of the player. Since I already hit them with the hitbox they stay in the relative position I hit them in and follow the player down. Once the attack animation ends I have it detach (the basis of the enemy attaching and detaching is through a bool in an in-between script. Although it doesn’t “pull” the enemy into the hitbox further, it’s at least a starting point and works for my test at least.
There are a couple of glitches such as the enemy getting stuck inside the player’s collider (I think), and the enemy going through walls while attached, however, both problems should be relatively easy to fix after I sleep on it.