So I’m trying to move a ball. The ball has a rigidbody2d and circle collider 2d for that sweet bounce material, but the ball won’t move at all. Here’s my code:
void Start()
{
_ballMoveSpeed = 2f;
_ballRigidBody = _ball.GetComponent<Rigidbody2D>();
_direction = new Vector3(Random.Range(-1, 2), Random.Range(-1, 2), 0);
1:)_ball.transform.Translate(_direction * _ballMoveSpeed * Time.deltaTime, Space.World);
2:)_ballRigidBody.MovePosition((_ball.transform.position + _direction) * _ballMoveSpeed * Time.deltaTime);
}
I’ve tried transform.translate (example 1) but nothing.
Tried using rigidbody2d.moveposition (example 2) still nothing. Tried increasing the speed also no movement. I get the _direction through debug logs and when I put a log at the end it gets there but the ball still won’t move. What am I doing wrong? Thanks!
Edit: I tried using rigidbody2d body types dynamic and kinematic and added and removed mass still nothing. But when I changed gravity scale from 0 to 1 it started to fall as expected. That’s the only movement I got from it so far.
Edit 2: I also converted the Vector3 _direction to Vector2 and still nothing