Unity Crash

I have a getter script in C# placed on a human model imported from 3dsmax, I want it to return some rigidbodies which i want to assign as connectedBodies for some hingeJoints in another script. When i want to use those getters, Unity crashes without warning or anything.

and the thing is i havea similar script placed on another object, which returns GameObjects, that one works, this one doesn’t

here’s the script:

using UnityEngine;
using System.Collections;

public class GetRigidBodies : MonoBehaviour {
	private Rigidbody lToe;
	private Rigidbody rToe;
	private Rigidbody lHand;
	private Rigidbody rHand;
	
	
	
#region getter for joints
	
	public Rigidbody LToe{
		get { return LToe; }
	}
	
	public Rigidbody RToe{
		get { return rToe; }
	}
	
	public Rigidbody LHand{
		get { return lHand; }
	}
	
	public Rigidbody RHand{
		get { return rHand; }
	}
	
#endregion
	
	void Awake(){
		foreach(Rigidbody temp in gameObject.GetComponentsInChildren<Rigidbody>()){
			Debug.Log("============== " + temp.name);
			if(temp.name == "Bip001 L Toe0"){
				lToe = temp;
			}
			if(temp.name == "Bip001 R Toe0"){
				rToe = temp;
			}
			if(temp.name == "Bip001 L Hand"){
				lHand = temp;
			}
			if(temp.name == "Bip001 R Hand"){
				rHand = temp;
			}
		}
	}
}

in the other script i have the next line of code:

lPedalRender.transform.FindChild("LPEDAL").rigidbody.hingeJoint.connectedBody = ciclist.GetComponent<GetRigidBodies>().LToe;

Someone else have the same problem?

i tried instead of

lPedalRender.transform.FindChild("LPEDAL").rigidbody.hingeJoint.connectedBody

to use this:

lPedalRender.GetComponentInChildren<HingeJoint>().connectedBody

same result, crash :expressionless:

public Rigidbody LToe{         
    get { return LToe; }     
}

should be

public Rigidbody LToe{         
    get { return lToe; }     
}

Please read through your own codes before posting. It’s a matter of typo i think.

thanks zine, that typo escaped me, and i read, re-read, but couldn’t see it… and unity didn’t warn me i am trying to return the function itself, since it thought it was recursive, i think…

anyways… thanks again. it solved the problem.

Oh well. Guess i got to of some help. Just be extra careful when you are typing. I am used to debugging. :smile: