title: Staying with player on a moving object with physics and rigidbody doesn't work in Unity
body: <p>I am trying to make character controller that can stand on a ground of a moving train that is using wheel coliders,rigidbody and simple script to go forward. I tryed a lots of tutorials where they make PlayerController as a child of a platform that is moving, but it is not working when I use scripts like :</p>
  
  <pre><code>{
      public GameObject Player;
  
      private void OnTriggerEnter(Collider other)
      {
          if(other.gameObject == Player)
          {
              Player.transform.parent = transform;
          }
      }
  
      private void OnTriggerExit(Collider other)
      {
          if (other.gameObject == Player)
          {
              Player.transform.parent = null;
          }
      }
  }
  </code></pre>
  
  <p>This is how my "train" works. It is like a normal car, but it is sliding in a rail in which are 2 colliders under each wheel.</p>
  
  <p>Train body picture in editor:
  <img src="https://i.stack.imgur.com/ALQDl.png" alt="Editor screenshot"></p>
  
  <p>With that script my Player object goes into child of a train, but when the train is moving, player stays in one place anyways, or the physics goes crazy and it will clip to it, but it has different speed than train and its sliding to a random places. I think it is because script that I use is usually used with animated platforms and not platforms with physics. I am really new to unity and coding so I would be really happy if anyone could help me fix my problem.</p>