# Billboarding sprite, rotating on a separate axis

I’m doing a 2.5D game with flat sprites that billboard to face the camera, rotating on the Y axis. I also want them to continuously rotate on the Z axis for a smooth spinning visual.

I don’t have a great understanding of Unity’s transform and rotation and can’t get these two ideas working at the same time together.

My sprites have this to manage billboarding:

``````transform.rotation = camera.transform.rotation;
transform.rotation = Quaternion.Euler(0f, transform.rotation.eulerAngles.y, 0);
``````

And hypothetically this works to rotate a sprite, but it’s not working together with the billboarding idea.

``````transform.Rotate(0, 0, speed * Time.deltaTime);
``````

Any help is greatly appreciated, thank you.

Try to += Vector3(x,y,z) to the Euler angles.

or rather

+= Sprite.transform.right to the Euler angles.

Make a short hierarchy of Transforms parented together, something like:

``````MySpinningOnZTransform
TheActuaSprite```

Only do the "billboard" the MyBasePrefab object (eg, rotate it around Y axis to face camera)

Always spin the MySpinningOnZTransform by setting its .localRotation:

``````

MySpinningOnZTransform.localRotation = Quaternion.Euler( 0, 0, Time.time * 200);

1 Like

I thought further about this one after I had posted and he could make an int that climbs from 0-360 maybe, possibly, and then he could have his transforms forward = camera transform forward + ((vector axis) * Int degree)

1 Like

Thanks so much for both of your suggestions - ended up going with the Transforms solution. Visualizing things in the Hierarchy window is a lot more clear to me, and this worked perfectly.