Hey,
While setting up a moving Camera, I’ve noticed that the z position from the “Car” object keeps changing when the “Horizontal” Input changes. I pretty much copied the code from the course. It doesn’t really break anything, but I still wonder why this is happening.
“DriverScript”
public class Driver : MonoBehaviour
{
[SerializeField] int SteerSpeed = 220;
[SerializeField] float MoveSpeed = 10.5f;
float SteerAmount;
float MoveAmount;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
SteerAmount = Input.GetAxis("Horizontal") * SteerSpeed * Time.deltaTime;
MoveAmount = Input.GetAxis("Vertical") * MoveSpeed * Time.deltaTime;
transform.Translate(0, MoveAmount, 0);
transform.Rotate(0, 0, -SteerAmount);
}
}
“CameraScript”
public class FollowCamera : MonoBehaviour
{
[SerializeField] GameObject Car;
void LateUpdate()
{
transform.position = Car.transform.position + new Vector3 (0,0,-5.5f);
}
}
Car Position after moving a bit: