Unity 2D Random Movement

Hi everyone, I’m simply trying to make a ball move in random directions (and bounce off the sides of the walls), and this is my script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyEasyAI : MonoBehaviour {
	public Rigidbody2D rb;
	public float speed = 1;
	// Use this for initialization
	void Start () {
		rb = GetComponent<Rigidbody2D> ();

	void FixedUpdate(){
		Vector2 Movement = new Vector2 (Random.Range(-1, 1), Random.Range(-1, 1));
		rb.AddForce (Movement);
		print (Movement);


However, what happens whenever I execute the script is that the gameobject simply moves down and to the left, and then stays put at the corner (the corner of the wall where it is being blocked by the colliders). How can I edit it so that the ball moves in a random and sporadic fashion? Any help would be appreciated.

I’d try setting a random direction every 1-2 seconds or so and then stay with that, and apply force in that direction, until you change it again. If you randomize every (fixed) frame, you don’t have enough time to accelerate.

public float accelerationTime = 2f;
public float maxSpeed = 5f;
private Vector2 movement;
private float timeLeft;

void Update()
  timeLeft -= Time.deltaTime;
  if(timeLeft <= 0)
    movement = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
    timeLeft += accelerationTime;

void FixedUpdate()
  rb.AddForce(movement * maxSpeed);

Note that I replaced the ints in the Random.Range calls with floats so you can get anything between -1 and 1 instead of just -1, 0, or 1. Your choice, of course.