- Home /
How to move an object with its parent?
Hello everybody, My question is how to make my 3rd person controller as an object's child. In my project, I have a 3rd person controller and a moving platform. When I jump on the platform, I want to make my player move wherever the platforms move. So I decided to make my player child of platform so they can move together. I tried this code but it didn't work.
void OnTriggerEnter(Collider other) {
if(other.tag == "platform")
{
Debug.Log(transform.parent);
transform.parent=other.transform;
Debug.Log(transform.parent);
}
}
When I jump on the platform, I saw on my console that my parent object changes to my platform but they don't move together. Any ideas to solve this problem?
Your answer
![](https://koobas.hobune.stream/wayback/20220613085202im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2d: Animating a child's transform will lock the Parent in place 0 Answers
Enemy Move towards object and hold it and use object 1 Answer
Adressing a Child Object after it´s unparented 0 Answers
Getting the topmost parent 1 Answer
Is Physics.SyncTransforms() automatically called in built game? 0 Answers