Random vector within a range, Quaternion issue...

Hi everybody,
Hope someone can help me, i’m stuck with quaternion.
So my problem is :

I want to spawn particles around my emitter between two angle

        Quaternion max = Quaternion.Euler(0.0f, 0.0f, _maxAngle);
		Quaternion min = Quaternion.Euler(0.0f, 0.0f, -_maxAngle);

		Vector3 maxVector = max * transform.up;
		Vector3 minVector = min * transform.up;

		Vector3 result = Vector3.Lerp(minVector, maxVector, Random.value);

		float particleSpeed = Random.Range(_particleSpeedMin, _particleSpeedMax);
		Vector3 speed = result * particleSpeed;

So if “_maxAngle” is equal to 30 particles spawn on a cone of 60° (between -30 and 30)

But

My problem is, if “_maxAngle” is equal to 180 so particles spawn in a straight line and not all around my emitter, i noticed that “maxVector” and “minVector” as the same value : (0,-1,0), but i don’t know how to manage the problem

Thanks for your attention and hope i can read you soon

look at your first two lines of code… you are using _maxAngle twice… one should be _minAngle

you will also want to Normalize result after the lerp. otherwise the vector length will be short sometimes… making slow speed

Well your main issue here is that you use Lerp between your vectors. You may want to use Slerp instead. However when you have an exact 180° angle it will still has difficulties to actually define a rotation plane and the result may not be what you think.

If you’re looking for a 3d version you may want to use something like my GetPointOnUnitSphereCap.