title: How to get projectile to move in the direction the player is facing
body: <p>This is the code for my player's movement:</p>
  
  <pre><code>var animator : Animator;
  
  function Start () {
      animator = GetComponent("Animator");
  }
  
  
  var moveUp : KeyCode;
  var moveDown : KeyCode;
  var moveLeft : KeyCode;
  var moveRight : KeyCode;
  var jumpheight : int = 2;
  var speed : int = 2;
  var isGrounded : int = 0;
  
  // Checks if player is in air or ground
  
  var Jumptest : int = 0;
  
  // Checks if player has jumped
  
  function Update () {
  
      animator.SetInteger("Direction", 4);
  
      if (Input.GetKey(moveUp) &amp;&amp; isGrounded == 0)
      {
          rigidbody2D.velocity.y = jumpheight;
          isGrounded = 1;
          animator.SetInteger("Direction", 2);
      }
  
  
      else if (Input.GetKey(moveLeft))
      {
          transform.position += Vector3.left * speed * Time.deltaTime;
          animator.SetInteger("Direction", 3);
      }
      else if (Input.GetKey(moveRight))
      {
          transform.position += Vector3.right * speed * Time.deltaTime;
          animator.SetInteger("Direction", 1);
      }
  
  }
  </code></pre>
  
  <p>and this is the code for the projectiles movement:</p>
  
  <pre><code>#pragma strict
  
  var speed  = 8.0;
  var time = 0.0;
  
  
  function Start () {
  
  }
  
  var moveRight : KeyCode;
  var moveLeft : KeyCode;
  
  function Update () {
      time += Time.deltaTime;
      if(time &gt; 3){
          Destroy(gameObject);
      }
  
      transform.Translate(Vector3.right * speed * Time.deltaTime, Space.Self);
  }
  </code></pre>
  
  <p>At the moment, the projectiles shoot to the right. I want to be able to shoot them in the direction the player is facing. </p>
  
  <p>I tried if key down a and if key down d but then the projectiles stop when the player is not moving and move relative to the player (if I shoot one going left, then move my player to the right, the projectile reverses direction).</p>
  
  <p>Anybody know?</p>