I'm currently working on a 2D game, where character is moving around a circle, but for now it's made with rb.MovePosition(), and I need to make it somehow else to detect colliders the way I want. For now my character is shaking beside the wall and simply go through it.
Here's my code:
private void Update()
{
if (Input.GetKey(KeyCode.A))
{
_oldAngle = _angle;
_angle += _speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.D))
{
_oldAngle = _angle;
_angle -= _speed * Time.deltaTime;
}
}
private void FixedUpdate()
{
var position = new Vector2(Mathf.Cos(_angle * Mathf.Deg2Rad),
Mathf.Sin(_angle * Mathf.Deg2Rad));
_rb.MovePosition(_startPosition + position * _radius);
}
I’ve tried to switch rigidbody types, add rigidbody to the wall, edit colliders, nothing helps.
Any thoughts?