Answer the question
In order to leave comments, you need to log in
Movement not working, how to fix it?
The player does not move. Doesn't throw errors.
Here is my code:
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);
}
Answer the question
In order to leave comments, you need to log in
The logic of the Fix() method does not work.
You need to call it in FixedUpdate().
Besides, in
rb.MovePosition(rb.position + moveVelocity + moveInput);
rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question