"Player movement with arroy keys and W,A,S,D keys"
xxxxxxxxxx
public class PlayerMove : MonoBehaviour
{
public float moveSpeed = 3;
public float leftRightSpeed = 2;
public float jumpForce;
private Vector3 direction;
private CharacterController controller;
public void Start()
{
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.forward * Time.deltaTime * moveSpeed, Space.World);
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
{
if (this.gameObject.transform.position.x > LevelBoundry.leftSide)
{
transform.Translate(Vector3.left * Time.deltaTime * leftRightSpeed);
}
}
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
{
if (this.gameObject.transform.position.x < LevelBoundry.rightSide)
{
transform.Translate(Vector3.left * Time.deltaTime * leftRightSpeed * -1);
}
}
}
}