Input.GetButton not working

Hello guys. I would ask for your help to solve my problem. I have a cube that walks among an array of gameobjects and this works fine. But the function ’ Input. GetButton ’ or any other similar command does not work. Below is the code:

  public Transform[] pathNodes;
  public float movementSpeed = 0.5f;
  public bool continuouslyLoop = false;
  private float pathPosition = 0f;
  private int curNode = 0;
  
  void Update () {
      if (pathNodes != null)
      {
          pathPosition += Time.deltaTime * movementSpeed;
          if (pathPosition > 1f)
          {
              if (pathNodes.Length > curNode+2)
              {
                  pathPosition = 0f;
                  curNode += 1;
              }
              else
              {
                  if (continuouslyLoop) 
                  {
                      pathPosition = 0f;
                      curNode = 0;
                  }
              }
          }
          transform.position = Vector3.Lerp( pathNodes[curNode].position, pathNodes[curNode+1].position, pathPosition );
      }

      if (Input.GetButtonDown("Jump")) {
          Jump();
	  }

  }

transform.position = Vector3.Lerp( pathNodes[curNode].position, pathNodes[curNode+1].position, pathPosition );

You’re lerping the positions while trying to use AddForce to jump. You’re lerping every frame, so the velocity doesn’t really have time to throw the object into the air.

Remember that Rigidbodies run on a seperate loop and you generally don’t want to adjust position when you have a rigidbody or addforce when you have a position.
Use LookAt to make your object face then nodes then AddForce(transform.forward, floatForceAmount) or set velocity to propel it forward.

Do this in FixedUpdate()

Otherwise, adapt your node position so that you add a vertical vector to it that represents the current jump height.

Hope this helps.