Child Not Keeping Up With Parent Translation

Hi all,

So I have this player which throws a sword for an infinite distance, and as soon as it passes over an enemy gameObject the enemy would stop it’s movement (rigidbody2d simulation deactivated) and become a child to the sword and fly along with it.

The problem is that along the distance traveled by the sword, the distance between the sword and the enemy child object keeps increasing. Shouldn’t it be stuck to the sword and stay this way no matter where the sword goes?

This is a 2D game using Physics2D and both sword and enemy have RigidBody2D components if that makes a difference. I also made sure they both have the same mass values and gravity is set to 0 in Physics2D settings.

Any ideas?

Problem solved!

I found out that a Follow Target script on the enemy gameObject was causing this. the script has a Vector3.MoveTowards bit to chase the player and even when the enemy’s physics simulation is off on death this script creates some sort of ‘pull’ towards the player.

I simply added a line to disable the Follow Target script when the enemy is killed and now it’s always in position with the flying sword.