Transform ---> Null Reference expection in assignmet

Hi Guys,

I have this piece of code, where I just want to save the current position of an object before it is moved somewhere else:

	print("position for design: " + transform.position);
***	print("pos: " + tmpObjSettings.position + " " + tmpObjSettings);
	
	tmpObjSettings.position = transform.position;
	tmpObjSettings.rotation = transform.rotation;
	print("Trasform: before " + tmpObjSettings.position);
	
	transform.position = tmp_pos.position;
	transform.rotation = tmp_pos.rotation;
	
	print("Transform After " + transform.position);

but at the *** position I receive this error (tmpObjSettings is declared as "PRIVATE VAR tmpObjSettings: Transform):

NullReferenceException
UnityEngine.Transform.get_position () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/BaseClass.cs:771)
i_SelectObject.SetPositionForDesign () (at Assets/Standard Assets/iScripts/i_SelectObject.js:38)
i_SelectObject.OnMouseDown () (at Assets/Standard Assets/iScripts/i_SelectObject.js:68)
UnityEngine.SendMouseEvents:smile:oSendMouseEvents()

Can anybody tell me what’s wrong?

Best,
Giancarlo

Try to check if tmpObjSettings is null.

Well, I declared tmpObjSettings as a Transform…and then I need to take the transform so … basically I think initially is null, do I need to call

tmpObjSettings = new Transform;
??

Regards,
GC.