Problem With Camera Transform

Hey, I have problem with this code and I don’t know what to do.
He writes me this misstake: NullReferenceException: Object reference not set to an instance of an object

m_Camera.transform.position = Vector3.Lerp(m_Camera.transform.position, new Vector3(m_Camera.transform.position.x, m_CharacterController.transform.position.y + (target_height / 2) - 0.1f, m_Camera.transform.position.z), 5f * Time.deltaTime);

I will be glad for any feedback.

NullReferenceException means you’re trying to use a variable that doesn’t have any value assigned to it. Basically, that can happen any time you put a “.” after the variable that doesn’t have a value.

So probably either m_Camera or m_CharacterController has not had any value assigned to it when your code is running. If those are public fields, and you look at this object in Unity’s inspector, you’ll probably see that one or both of them has a value of “none” or “missing”.

2 Likes

Oh yes I got it thank you.