Super weird Rigidbody MovePosition issue

Hello guys!
I was messing around with rigid bodies when I ran into a problem that puzzles me to say the very least.

I have a camera which smoothly follows the GameObject I’m controlling, which in turn can only move back and forth upon the Z-axis. Really simple stuff.

Now, the problem is the camera seems to move in a clunky flickering way depending on the type of variable I use to store the Z-movement from the Input.
Precisely, if I use a floating point variable, the movement’s smooth.
On the contrary, if I use a Vector3 and just consider its z field, stuff goes crazy.

This is the script controlling the camera:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour 
{
	[SerializeField] Transform cameraTarget;
	[SerializeField] bool smoothingEnabled;
	[SerializeField] float damping;

	Vector3 offset;
	Vector3 initialRotation;
	Vector3 targetPosition;
	Quaternion targetRotation;

	void Awake()
	{
		offset = transform.position - cameraTarget.position;
		initialRotation = transform.rotation.eulerAngles;
	}

	void FixedUpdate()
	{
		targetPosition = cameraTarget.position + cameraTarget.right * offset.x + cameraTarget.up * offset.y + cameraTarget.forward * offset.z;
		targetRotation = Quaternion.LookRotation (cameraTarget.forward, Vector3.up) * Quaternion.Euler (initialRotation);
		if (!smoothingEnabled)
		{
			transform.position = targetPosition;
			transform.rotation = targetRotation;
		}
		else
		{
			transform.position = Vector3.Lerp (transform.position, targetPosition, damping * Time.deltaTime);
			transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, damping * Time.deltaTime);
		}
	}
}

And this is the script that controls my GameObject:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BuggyController : MonoBehaviour 
{
	public float speed;

	Rigidbody rb;
	float zMove;
	Vector3 movement;

	void Awake()
	{
		rb = GetComponent<Rigidbody> ();	
	}
	
	void Update () 
	{
		zMove = Input.GetAxisRaw ("Vertical");
		movement.z = zMove;
	}

	void FixedUpdate()
	{
		// Replace movement.z with zMove and the problem is somehow solved. WHY???
		movement = transform.forward * movement.z * speed * Time.deltaTime;
		rb.MovePosition(rb.position + movement);
	}
}

As you can see in BuggyController’s FixedUpdate, the problem arises if using movement.z and is solved using zMove, but movement.z has been set to zMove so it makes no sense to me.
What am I missing?

The problem is that movement.z will not always have the same value as zMove because you are overwriting the value in FixedUpdate.

You should either just use zMove in FixedUpdate or move the Input.GetAxisRaw ("Vertical") to FixedUpdate.