|
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) 2) 3) 4)
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) 8) Click Play - see rotating plane Case 1: Modeled Cylinder attached to Plane 1) 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
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
(comments are locked)
|
|
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. I apologize, but you lost me. Are you saying that the manual version is also incorrect even though it works? What should the dynamic version script look like to make it work like the manual version?
Apr 28 '10 at 06:02 AM
glewis
@glewis: When you manually created the cylinder, it has a collider, and the scripted version doesn't. Also the manually created cylinder is scaled to (.1, .5, .1) and the scripted version isn't. This makes them behave differently. Neither one of them is correct or not correct, they are just different. What's incorrect is using a mesh collider and a rigidbody together for the plane. You should get error messages for that. Replace the mesh collider for the plane with a box collider.
Apr 28 '10 at 08:11 AM
Eric5h5
OK, sorry about the scale differences... that was a typo on my part. I edited the text above and removed the scaling of the manual cylinder. I've tried out your suggestion, and I'm thinking that I may not have been clear enough in my original description. I'm trying to spin the plane about its center, and with the mesh collider, this works great. I want to add cylindrical "pegs" to the plane (as child objects) that spin along with the plane as if they are attached to it. With the box collider, the plane now spins around the peg, not what I want. I'll try to put together a video.
Apr 29 '10 at 06:33 AM
glewis
I've added 3 live examples to the original. I can put the project source somewhere if that would help.
Apr 29 '10 at 06:55 AM
glewis
(comments are locked)
|
