2D Game - Projectile should look into its moving direction

Hey guys,

i can fire a projectile in every direction in my 2d room.

	public void fire(){
		Vector3 location = target.transform.position;
		Vector3 location2 = new Vector3 (weapon.transform.position.x, weapon.transform.position.y, 28);
		
		GameObject clone;
		clone = Instantiate(projectile, location2, weapon.transform.rotation) as GameObject;
		Vector2 direction = (location - location2).normalized;
		clone.rigidbody2D.AddForce(direction * travelspeed);

		AudioSource.PlayClipAtPoint (shooting, new Vector3(0,0,0));
	}

I have a script on my projectile which should rotate my object after a collision (direction change) so that my projectile look in the direction its moving.

i tried it with that script:

	void Start()
	{
		rigidbody2D.fixedAngle = true;

	}

	void Update () {
		transform.rotation = Quaternion.LookRotation(rigidbody2D.velocity);
	}

Then i get this:

When i rotate my projectile on the z axis in the inspector it looks perfecty, so i guess i need to rotate my projectile in the code something like Vector3(0,0,angle)
Thanks for any help !

Assuming the right side of your 2D object is considered forward, I know this will work:

 float angle = Mathf.Atan2(rigidbody2D.velocity.y, rigidbody2D.velocity.x) * Mathf.Rad2Deg;
 transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

This may work:

  transform.right = rigidbody2D.velocity;