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?