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();
}
}