public float speed;
private Rigidbody2D rb;
private Vector2 moveInput;
private Vector2 moveVelocity;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical") );
moveVelocity = moveInput.normalized * speed;
}
void Fix()
{
rb.MovePosition(rb.position + moveVelocity + moveInput);
}
rb.MovePosition(rb.position + moveVelocity + moveInput);
rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime);