Skip to main content
Corrected format of code
Source Link
Gnemlock
  • 5.3k
  • 5
  • 28
  • 59

So I use this code, with a Rigidbody attached to my GameObject (player)..

using UnityEngine;

public class Player : MonoBehaviour {
{
    public float speed = 4f;
    private float movement = 0f;
    public Rigidbody2D rb;

    private void Update()
    {
        movement = Input.GetAxisRaw("Horizontal") * speed;
    }

    void FixedUpdate ()
    {
        rb.MovePosition(rb.position 
            + new Vector2(movement * Time.fixedDeltaTime, 0f));
    }
 
}

The problem is the movement feels jerky / not smooth. It might just be me, though.

No, this is not a duplicate of a similar question. I am using other code and it's not totally similar to what I'm doing

So I use this code, with a Rigidbody attached to my GameObject (player)..

using UnityEngine;

public class Player : MonoBehaviour {

public float speed = 4f;
private float movement = 0f;
public Rigidbody2D rb;

private void Update()
{
    movement = Input.GetAxisRaw("Horizontal") * speed;
}

void FixedUpdate ()
{
    rb.MovePosition(rb.position + new Vector2(movement * Time.fixedDeltaTime, 0f));
}
 
}

The problem is the movement feels jerky / not smooth. It might just be me, though.

No, this is not a duplicate of a similar question. I am using other code and it's not totally similar to what I'm doing

So I use this code, with a Rigidbody attached to my GameObject (player)..

using UnityEngine;

public class Player : MonoBehaviour
{
    public float speed = 4f;
    private float movement = 0f;
    public Rigidbody2D rb;

    private void Update()
    {
        movement = Input.GetAxisRaw("Horizontal") * speed;
    }

    void FixedUpdate ()
    {
        rb.MovePosition(rb.position 
            + new Vector2(movement * Time.fixedDeltaTime, 0f));
    }
}

The problem is the movement feels jerky / not smooth. It might just be me, though.

No, this is not a duplicate of a similar question. I am using other code and it's not totally similar to what I'm doing

added 119 characters in body
Source Link
fnTASY
  • 1
  • 1
  • 2

So I use this code, with a Rigidbody attached to my GameObject (player)..

using UnityEngine;

public class Player : MonoBehaviour {

public float speed = 4f;
private float movement = 0f;
public Rigidbody2D rb;

private void Update()
{
    movement = Input.GetAxisRaw("Horizontal") * speed;
}

void FixedUpdate ()
{
    rb.MovePosition(rb.position + new Vector2(movement * Time.fixedDeltaTime, 0f));
}

}

The problem is the movement feels jerky / not smooth. It might just be me, though.

No, this is not a duplicate of a similar question. I am using other code and it's not totally similar to what I'm doing

So I use this code, with a Rigidbody attached to my GameObject (player)..

using UnityEngine;

public class Player : MonoBehaviour {

public float speed = 4f;
private float movement = 0f;
public Rigidbody2D rb;

private void Update()
{
    movement = Input.GetAxisRaw("Horizontal") * speed;
}

void FixedUpdate ()
{
    rb.MovePosition(rb.position + new Vector2(movement * Time.fixedDeltaTime, 0f));
}

}

The problem is the movement feels jerky / not smooth. It might just be me, though.

So I use this code, with a Rigidbody attached to my GameObject (player)..

using UnityEngine;

public class Player : MonoBehaviour {

public float speed = 4f;
private float movement = 0f;
public Rigidbody2D rb;

private void Update()
{
    movement = Input.GetAxisRaw("Horizontal") * speed;
}

void FixedUpdate ()
{
    rb.MovePosition(rb.position + new Vector2(movement * Time.fixedDeltaTime, 0f));
}

}

The problem is the movement feels jerky / not smooth. It might just be me, though.

No, this is not a duplicate of a similar question. I am using other code and it's not totally similar to what I'm doing

Source Link
fnTASY
  • 1
  • 1
  • 2

My character movement doesn't feel smooth.. [Unity]

So I use this code, with a Rigidbody attached to my GameObject (player)..

using UnityEngine;

public class Player : MonoBehaviour {

public float speed = 4f;
private float movement = 0f;
public Rigidbody2D rb;

private void Update()
{
    movement = Input.GetAxisRaw("Horizontal") * speed;
}

void FixedUpdate ()
{
    rb.MovePosition(rb.position + new Vector2(movement * Time.fixedDeltaTime, 0f));
}

}

The problem is the movement feels jerky / not smooth. It might just be me, though.