I’m getting this error: NullReferenceException: UnityEngine.Transform.get_localRotation()
for this line right here:
motor.axle.Rotate(Vector3.up * motor.RPM * Time.deltaTime);
The variable motor
is this class:
public class SimMotor {
public bool active = true;
public string ID = "MA-1";
public float RPM = 1;
public float torque = 1;
public Transform motorBody = null;
public Transform axle = null;
public TextMesh systemDisplay = null;
public SimGear engagedGear;
public Material[] motorMaterials;
}
So motor.axle
is just the actual transform of the axle on the motor. I just want it to rotate but I keep getting that error. Any idea why?
Note: The ‘axle’ transform has no children.
Another note: It has nothing to do with the axle transform itself, because I get the error no matter what I set as the axle.
Another Another Note: I’m getting the feeling that Unity is weirding out because this only happened after the last update. Every single error I’m getting, I receive three times every frame and it treats it like they are all separate errors (even though I have Collapse on in the Debug log, there’s three separate errors and they happen every frame). No idea why this is happening.