Object Falls from Moving Platform

Its been more than two hours I have been searching and experimenting to make my object move with the moving platform …

Here’s the Code that is attached to moving platform. but still the object does not move along with the moving platform rather falls.

    public GameObject platform;
        public GameObject player;
        void OnCollisionEnter(Collision hit)
        		if (hit.gameObject.tag == "player") {
        		player.transform.parent = platform.transform;
        void OnCollisionExit(Collision hit)
     player.transform.parent = null;

And here’s an other script attached to platform for moving.

public Vector3 pointB;
	// Use this for initialization
	IEnumerator Start () {
		var pointA = transform.position;

		while (true) {

			yield return StartCoroutine(MoveObject(transform, pointA, pointB, 3.0f));
			yield return StartCoroutine(MoveObject(transform, pointB, pointA, 3.0f));


	IEnumerator MoveObject(Transform thisTransform, Vector3 startPos, Vector3 endPos, float time)
		float i = 0.0f;
		float rate = 1.0f / time;

		while (i < 1.0f) {
			i += Time.deltaTime * rate;
			thisTransform.position = Vector3.Lerp(startPos, endPos, i);
			yield return null;


Are you moving the platform with transform.Translate? Collisions are not computed for objects that are being moved by directly manipulating the transform. Try attaching a body to the platform and moving it with rigidbody.MovePosition to maintain the colliders integrity.

Also never move collision meshes that do not have a rigidbody attached (even if that body is basically inactive). Unity considers all objects with colliders that do NOT have rigidbodies to be part of the static collision mesh. If you move those objects it makes unity rebake the entire static collision mesh for every frame the object is in motion. This can be a pretty expensive operation you can circumvent by just placing another component on the object.