Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

correct movement

so i made player movemnt with these script, but when moving it kinda fills like it's lagging so is there better way to make movement?? i tried force but in was sliding arround and i could not fix it.

public Rigidbody rb;

public float leftspeed = -1500f;

public float rightspeed = 1500f;

public float forwardspeed = 2000f;

public float backwardsspeed = -1300f;

  // Start is called before the first frame update

  //void Start(){}

  // Update is called once per frame

  void Update()


     if (Input.GetKey(KeyCode.LeftArrow)){

     rb.transform.Translate(leftspeed * Time.deltaTime, 0, 0);


     if (Input.GetKey(KeyCode.RightArrow)){

     rb.transform.Translate(rightspeed * Time.deltaTime, 0, 0);


     if (Input.GetKey(KeyCode.UpArrow)){

     rb.transform.Translate(0, 0, forwardspeed * Time.deltaTime);


     if (Input.GetKey(KeyCode.DownArrow)){

     rb.transform.Translate(0, 0, backwardsspeed * Time.deltaTime);



Best Answer

  • jeromejerome Member
    Accepted Answer


    , ForceMode.VelocityChange

    at every end of your if statements like so

     rb.transform.Translate(leftspeed * Time.deltaTime, 0, 0, ForceMode.VelocityChange);


Sign In or Register to comment.