[SerializeField] float controlSpeed = 10f;
void Update()
{
float xThrow = Input.GetAxis("Horizontal");
float yThrow = Input.GetAxis("Vertical");
float xOffset = xThrow * Time.deltaTime * controlSpeed;
float newXPos = transform.localPosition.x + xOffset;
transform.localPosition = new Vector3 (newXPos, transform.localPosition.y, transform.localPosition.z);
}
This is my code. I couldn’t figure out on how to fix the issue. I used localPosition so it has to move on its X axis, not Z axis.