Constraining rotation to only the Y Axis

I was trying different bullet patterns for a shooter game, and noticed that the rotation on the Z axis has problems when there is movement on the player using a rigidbody,so the bullet patterns disappear/fade out when the player actually moves.

Is there a way to fix this I’ve tried using transform.rotation = Quaternion.Euler(0,20,0) to limit the rotation to only the y axis, but it feels a little messy. Is there an easy fix to this problem?

// Update is called once per frame
	void Shoot ()

void Start()
	rigidbody.velocity = transform.forward * speed;

You can check the lock rotation in editor for x and z, you can set via code with RigidBody constraints, and you can set the y of the transform.rotation with a Vector3(x,0,z) or a Quat. etc.

Take the easy route and lock the axis when it needs to be. I would do the first, or just set the constraints if you totally can’t limit the rotation axis in the editor.