title: Making an object move in a random direction in Unity
body: <p>I have an <code>EnemyTest</code> gameobject that, through an <code>EnemyDmg</code> script, instantiates a damage number whenever a weapon hits it. I would like to put a script on the damage number prefab that will make it move in a random direction in 2-dimensional space. I know other people have asked this, but the thing is, I would like to be able to move the damage number without rotating it, so that it can still be easily read. I am planning on putting the code for the damage number movement in a new script on the prefab, contained within a <code>void Awake()</code> method.</p>
  
  <p>This is the EnemyDmg script:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class EnemyDmg : MonoBehaviour
  {
      GameObject EnemyCanvas;
      public GameObject DmgNmbr;
  
      void Start()
      {
          EnemyCanvas = this.gameObject.transform.GetChild(0).gameObject;
      }
  
      void OnCollisionEnter2D(Collision2D Collider)
      {
          if (Collider.gameObject.tag == "Weapon")
          {
              Debug.Log("Enemy Hit!");
              Instantiate(DmgNmbr, EnemyCanvas.transform);
          }
      }
  }
  </code></pre>
  
  <p>As it currently is, this is what happens when a weapon hits the enemy: <a href="https://drive.google.com/file/d/11sCcXzythDh1hQFkBGHE7l7NoDfcl3t3/view?usp=sharing" rel="nofollow noreferrer">Google Drive Video</a>. I would like the yellow number to fly off of the enemy in a random direction, although it doesn't have to go very far. From this perspective, the x-axis is left and right, and the y-axis is up and down.</p>