Answer the question
In order to leave comments, you need to log in
How to remove object sliding when moving through Rigidbody MovePosition?
Hello, there is a Top Down project with the following movement implementation:
[RequireComponent(typeof(Rigidbody2D))]
public class Player : MonoBehaviour
{
[SerializeField] private float _speed;
private Rigidbody2D _rigidbody;
private Vector2 _movement;
private void Start()
{
_rigidbody = GetComponent<Rigidbody2D>();
}
private void Update()
{
_movement.x = Input.GetAxis("Horizontal");
_movement.y = Input.GetAxis("Vertical");
}
private void FixedUpdate()
{
_rigidbody.MovePosition(_rigidbody.position + _movement * _speed * Time.fixedDeltaTime);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question