• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Jean-Fabre · Aug 17, 2010 at 06:14 PM · connectedbodymissingfieldexception

connectedBody error when used in script

Hi,

I encounter a weird issue where I can't set the connectedBody of a configurable joint in my script.

I get the following:

MissingFieldException: Field 'UnityEngine.ConfigurableJoint.connectedBody' not found. Boo.Lang.Runtime.PropertyDispatcherFactory.EmitPropertyDispatcher (System.Reflection.PropertyInfo property, SetOrGet gos) Boo.Lang.Runtime.PropertyDispatcherFactory.EmitDispatcherFor (System.Reflection.MemberInfo info, SetOrGet gos) Boo.Lang.Runtime.PropertyDispatcherFactory.Create (SetOrGet gos) Boo.Lang.Runtime.PropertyDispatcherFactory.CreateSetter () Boo.Lang.Runtime.RuntimeServices.DoCreatePropSetDispatcher (System.Object target, System.Type type, System.String name, System.Object value) Boo.Lang.Runtime.RuntimeServices.CreatePropSetDispatcher (System.Object target, System.String name, System.Object value) Boo.Lang.Runtime.RuntimeServices+<>c_DisplayClass13.b_12 () Boo.Lang.Runtime.DispatcherCache.Get (Boo.Lang.Runtime.DispatcherKey key, Boo.Lang.Runtime.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, System.Object[] args, Boo.Lang.Runtime.DispatcherFactory factory) [0x00000] Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Object[] args, Boo.Lang.Runtime.DispatcherFactory factory) [0x00000] Boo.Lang.Runtime.RuntimeServices.SetProperty (System.Object target, System.String name, System.Object value) rig builder.Awake () (at Assets/rig builder.js:19)

What is really weird is that in the project view in my prefab, using the inspector doesn't work neither I get the list of available nodes I can select but nothing is actually set and connectedBody fields remains empty. There is only one way and it's in the scene itself, but that defeats the purpose of setting it up.

Any help or advice is welcome. Here is the script in question just in case.

function Awake(){

 var frame = GameObject.Find("physics_frame_tracks");
 var frame_colliderComp = frame.AddComponent(BoxCollider);
 var frame_rigidbodyComp = frame.AddComponent(Rigidbody);
     frame_rigidbodyComp.isKinematic = true;


 var bodyRB = GameObject.Find("physics_body");
 var body_colliderComp = bodyRB.AddComponent(MeshCollider);
     body_colliderComp.convex = true;

 var body_rigidbodyComp = bodyRB.AddComponent(Rigidbody);

 var frame_joint = frame.AddComponent(ConfigurableJoint);
 frame_joint.connectedBody = bodyRB; // !!!!!error here!!!!

note that ALL the other properties of the configurableJoint can be set properly without problem in this script too,

Thanks for your help,

Jean

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Jean-Fabre · Aug 18, 2010 at 12:55 PM

ok,

The problem is odd, it actually fails because I was passing the wrong type as value, connectedBody expect a RigidBody component, and I was passing the GameObject instead.

This is confusing, but kind of make sense once you know it. I would expect a bit more documentation on this, if it is there, I missed it sorry and would like to hear about where exactly this kind of juggling is described.

the last line must be

frame_joint.connectedBody = bodyRB.GetComponent(Rigidbody);

and it all works fine then.

see http://answers.unity3d.com/questions/18453/convert-gameobject-to-rigidbody-type/

for the same problem the other way round ( cause if you try this on a var you declare yourself, the error is different and more at first more appropriate).

Jean

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bwheatley · Jun 23, 2012 at 07:54 AM 0
Share

The new link for the answer you posted is now http://answers.unity3d.com/questions/25320/convert-gameobject-to-rigidbody-type.html

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Getting variables after Resources.LoadAll 1 Answer

Joint connected body not working 1 Answer

ERROR: missing field exception 1 Answer

Hinge joint connected body scripting issues 1 Answer

Missing Field Exception: Field "UnityEngine.TextMesh.text" not found 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges