title: 2d platformer enemy movement
body: <p>I have been researching for at least two hours on how to make an enemy character that moves left and right on a platform without falling off. I have tried out 4 different scripts and gone through 2 youtube tutorials but I just seem to be getting errors on everything. This is my first post so please notify me if i'm doing anything wrong, thank you :).</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class EnemyPatrol : MonoBehaviour {
  
      public float MoveSpeed;
      public bool MoveRight;
      public var velocity: Vector2;
  
      void Update () 
      {
          if (MoveRight) {
              public bool GetComponent&lt;rigidbody2D&gt;().velocity = 
                new Vector2(MoveSpeed, rigidbody2D.velocity.y);
          } else {
              public bool GetComponent&lt;rigidbody2D&gt;().velocity = 
                new Vector2(-MoveSpeed, rigidbody2D.velocity.y);
          }
      }
  }
  </code></pre>
  
  <p>My errors:</p>
  
  <pre><code>Assets/Scripts/EnemyPatrol.cs(8,28): error CS1519: Unexpected symbol \`:' in class, struct, or interface member declaration  
  Assets/Scripts/EnemyPatrol.cs(8,37): error CS1519: Unexpected symbol \`;' in class, struct, or interface member declaration  
  Assets/Scripts/EnemyPatrol.cs(13,30): error CS1525: Unexpected symbol \`public'  
  Assets/Scripts/EnemyPatrol.cs(15,30): error CS1525: Unexpected symbol \`public'
  </code></pre>