Dynamic (scripted) vs Static (modeled) parenting - physics behaves differently

Say I created a small plane and wish the physics engine to spin it for me then come to a halt due to angularDrag. This works great.

Now, if I model a cylinder as a child of the rotating plane, it still works great.

But if I add a cylinder to the plane in the plane's Start function, the physics engine appears to get totally confused and will no longer spin the plane correctly.

Here are the steps to demonstrate this problem:

1) `New Project`

2) `Game Object / Create Other / Plane` - Position (0,0,0) - keep it selected

3) `Component / Physics / Rigidbody` - turn off Gravity

4) `Project / Create / JavaScript` - rename it RotatePlane - make it say this:

  function Start () {

5) Drag RotatePlane script under Plane object in hierarchy

6) Select Main Camera - set Position (0,15,0), Rotation (90,0,0) so we can see the plane

7) `GameObject / Create Other / Spotlight` - Position (0,20,0), Rotation (90,0,0) to light the plane

8) Click Play - see rotating plane

Case 1: Modeled Cylinder attached to Plane

1) `GameObject / Create Other / Cylinder` - set Position to (-2.5,1,0)

2) Drag the Cylinder under the Plane to parent it to the plane

3) Click Play - see rotating plane with cylinder - works great

See: http://www.hometot.com/unity/spin_works.html

See also: http://www.hometot.com/unity/wheel_works.html

Case 2: Dynamically-created Cylinder attached to Plane

1) Edit the RotatePlane script

function Start () {

    var comp = GameObject.Find("Plane");
    var cylinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
    cylinder.transform.parent = comp.transform;
    cylinder.transform.localPosition = Vector3(-2.5, 1, 0);


2) Now click on Play and let run for a few seconds - the physics engine appears to get confused.

See: http://www.hometot.com/unity/wheel_broken.html

Any ideas what I'm doing wrong?

Thank you!

-- Glenn

Those aren't the same thing...one, the manually created cylinder has a collider and the scripted cylinder doesn't, and they are scaled differently. Also, you shouldn't be adding a rigidbody to a mesh collider like the plane has; change it to a box collider instead.