- Home /
Unity thinks my Quaternion is a Float
Hello,
I am trying to set the rotation of an emitted particle from a ParticleSystem to the direction it is travelling in.
This is my code:
void RotateParticles()
{
ParticleSystem.Particle[] x = new ParticleSystem.Particle[gameObject.particleSystem.particleCount+1];
int y = particleSystem.GetParticles(x);
for(int i = 0; i < y; i++)
{
Vector3 offset = gameObject.transform.position - x[i].position;
if(offset != gameObject.transform.position)
{
Quaternion rotationPoint = new Quaternion();
rotationPoint.SetLookRotation((offset), Vector3.up);
x[i].rotation = rotationPoint;
}
else
Debug.Log("False");
}
gameObject.particleSystem.SetParticles(x, y);
}
The error thrown is 'cannot convert type UnityEngine.Quaternion to float' however, as far as I can tell, both the particle.rotation and rotationalPoint variables are in fact quaternions.
Either I'm totally wrong and the Quaternion variable I have just created isn't a Quaternion at all (assuming Unity throws its errors respectively) OR they are both quaternions and this error is false OR the rotation of a particle is not a Quaternion (assuming Unity doesn't throw its errors respectively).
I'm lost!
Any and all help appreciated.
Answer by missingno · Apr 02, 2014 at 07:34 PM
x[i].rotation is a float.
Thanks missingno - I can't believe I missed this. Unfortunately this still leaves me with the task of figuring out how to do what I want, namely: altering an individual particle's 'face' (look?) direction
I assume thats a float because an particle its a billboard, so it will be always looking to the camera, you can only control de z axis rotation.
Answer by perchik · Apr 02, 2014 at 07:33 PM
Look at the documentation, ParticleSystem.Particle.Rotation is a float.
Your answer
Follow this Question
Related Questions
Rotation to go from one direction to another? 0 Answers
Bone Rotation on X (or any) axis Issues 1 Answer
Creating Hint Vector 1 Answer
Quaternion amount/value of rotation? 2 Answers
LookAt on only 1 axis for 2D games? 1 Answer