- Home /
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?
Answer by AShenawy · Aug 01, 2018 at 08:00 PM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172016im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Make a simple tree 1 Answer
Instantiate as child Issue regarding 2D platformer melee system 0 Answers
[MovePosition() on parent] + [angularVelocity = x on child] = problem. Unity 2D 1 Answer
Clicking on a child object. 1 Answer
Setting children position to Vector3.zero doesn't make them go to center of parent? 1 Answer