Inspector transform values not agreeing with values found in Visual Studio

I have been fighting with this problem for a long time now, and it’s time for me to seek help.

I’ve got my main camera zooming in and out of my scene, using Vector3.Lerp() in FixedUpdate(), as needed. Initially, it’s position needs to be at (0, 0, -40): when I don’t have a FixedUpdate, and set these initial values in script, it’s position is perfect. My camera position code in my setup is as follows:

 private void Start()
 {
       Vector3 startPosition = new Vector3(0, 0, -40f);
       _camera.transform.position = startPosition;
      _newCameraPosition = startPosition;
  }

As seen in the following graphic, when I set a breakpoint in my FixedUpdate(), and inspect my Camera’s position, everything looks like it should:

However, the camera is Lerp’ed to the wrong place, and the Inspector shows:

205085-inspector-camera-transform-values.png

the Inpector shows the Camera’s position as being moved to (-11.25, -11.25, -51.25), and in the game I can see the camera movement as described by my FixedUpdate():

Also note that if I discount FixedUpdate(), and use the inspector to reset the position to (0, 0, -40), it’s exactly what I need.

private void FixedUpdate()
{
     Vector3 a = _camera.transform.position;
    Vector3 b = _newCameraPosition;
    _camera.transform.position = Vector3.Lerp(a, b, Time.deltaTime * _cameraLerpSpeed);
 }

Please note that nothing has altered the Vector3_newCameraPosition at this point, and nothing else is moving the camera, besides my FixedUpdate(), which shouldn’t be doing anything since _camera.transform.position and _newCameraPosition are equal.

I think this is the 'last" big problem that I’m facing before I can say "my game is playable and I’m ready publish my game (ignoring that I still have to build my help system, and weeks of testing needed to prepare everything for publishing. And I know that there are other mounds of unknown work that need to be done–I am very new to this.)

I should add that it doesn’t seem to have anything to do with the Lerp() function. If I set the Camera Position explicitly in code (i.e., _camera.transform.position = New Vector3(0, 0, -40); doesn’t help. the camera is automatically down, to the left and back (-11.25, -11.25, -51.25) (in the inspector), and adjusting the position values to (0, 0, -40) via the Inspector brings the camera back to where it belongs.

It’s impossible to tell you just how grateful I would be if anyone could PLEASE HELP me past this issue!

Thank you sincerely

The position in the inspector shows the local position, while transform.position represents the global position of the object. Without knowing more about your project and your transform hierarchy, my guess would be that that’s where the problem lies.