The gameobject turns only once after colliding with another gameobject.

void OnCollisionEnter2D(Collision2D collisionn)

{

	if(collisionn.gameObject.tag == "blackbox")
	{
		
		rotate = transform.rotation;
		rotate.y += 180f;
		transform.rotation = rotate;
	}
}

So , i started playing around with Unity yesterday so I am very new.What i want to do is to make a walking bucket rotate 180 degrees when it comes in collision with the “blackbox” ,but with this script it rotates only after the first collision , then the bucket walks in the other direction but stops after coming in collision with another “blackbox” . Also , i forgot to say that it is a 2D ‘game’ .
Please help

You are trying to rotate a Quaterinion as you would in a normal Euler angles representation, and that just doesn’t work. Use transform.Rotate(Vector3 eulerAngles) Unity - Scripting API: Transform.Rotate instead.

If you want see: Unity Connect to have a simple explanition about unitys Quaternion usage.