using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMotor_2 : MonoBehaviour
{
public int Direction;
void Start()
{
}
void Update(){
Analyze ();
if (Input.GetKeyDown (KeyCode.D)) {
print ("left");
if (Direction == 0 || Direction == 1) {
Direction--;
}
} else if (Input.GetKeyDown (KeyCode.A)) {
print ("right");
if (Direction == 0 || Direction == -1) {
Direction++;
}
}
transform.Translate(5f * Time.deltaTime, 0f, 0f);
}
void Analyze(){
transform.position = Vector3.Lerp (transform.position, new Vector3 (0, 0, 3 * Direction), 0.1f);
}
}
I managed to move the character to the right and to the left but I can not make it go on endlessly