Hey there!
I’m trying to get some billboaring scripts working.
Currently I have…
Vector3 camDirection = Camera.main.transform.position - transform.position;
if(velocity!= Vector3.zero)
{
transform.rotation = Quaternion.LookRotation (velocity, camDirection);
transform.Rotate (Vector3.right,90f);
}
It rotates the particle based on its velocity, but then rotates it by it’s y axis so that it faces the camera. The final 90 degree rotation is a tweak to get it exactly how I want.
It works perfectly but whenever I try to have an arbitrary rotation for x and z (like with rotation velocities) I can’t get it perfect. I get close but certain angles don’t line up correctly.
Specifically I have a vector3 for a rotation velocity and a separate quaternion to hold the rotations and then I apply the final rotation + billboarding to transform.rotation.
I’m looking for a way to have independent rotations and then apply a final rotation for the x and/or y and/or z axes to align to the camera.
This comes close…
vector3 camRotation = Quaternion.LookRotation(camDirection).euler;
camRotation.x = 0;
camRotation.y = 0;
transform.rotation = savedRotation * Quaternion.Euler (camRotation);
But obviously just zeroing out values isn’t how rotations work.
Quaternion.LookRotation seems like the best bet, but I don’t know how to make my current rotation into the form of a Vector3 direction.
Any help would be greatly appreciated.