Making object always face an isometric camera (orthographic)

I am prototyping a few different ideas at the moment and one problem I have at the moment is that I have an isometric style camera (30, 45, 0 rotation on base object then child camera -10 on Z).

Then I have a cylinder which is of scale 4,10,4 so its really long, then I need the top of it to face the camera. So think of it like holding a can of coke and you want to always see the ring pull and not the sides.

Now I have tried doing transform.LookAt and using the cameras forward or position normalized and that doesnt work, and although I can manually find the sweet spot around (332, 117, 305) I have lots of other instances of the cylinder around the game world which also need to face the camera and I do not think the rotation will be the same for them.

So is there a way to do this given that the camera is rotated under a child etc?

Just take the Camera orientation, inverse it, and apply it to your object. In an ortho camera, you don’t want to look at the camera, you want it to face the same direction as the camera.

I got the rotation of the camera, inverted it using Quaternion.Inverse(targetRotation); then applied that rotation to the transform of the cylinder, but it does not point towards the camera, it just seems to point upwards, here is a screenshot to make it more apparent as to what I am after:

The top is how it looks doing the above, and the bottom is ideally what I am after.

Could it be that your mesh is using Y as its sight, while if I remember well, the Camera is using Z for its sight.

Two solution, you change your mesh so that points in Z, or your code something to translate Y to Z (or vise versa).

its a cylinder, so not a custom mesh. Everything in the scene is either a cube, plane or a cylinder. Sorry for the following question but how do I change the cylinder to use Z for its sight?

Does your camera change rotation or just stay the same direction? It has to be rotating or else it would just be easier to manually set the sweet spot.

You could just put the cylinder inside another game object and rotate that gameobject instead of the cylinder and rotate the cylinder to compensate for the difference.

If you`d rather do it by script, have an adjustment Quaternion and combine it with the LookAt rotation in the script:

The camera follows the players position but its rotation never changes, it is set up in an isometric (with orthographic) style so it should always be the same.

The only reason I want to do it via script is because there will be a lot of these cylinders in the scene (one for every entity), and they may be different distances so I am not sure if the ideal angle would be different for them as the camera is following the player (positionally) not them, if that makes sense…

I did try doing an adjustment however the eular seem to have little bearing on what the quaternion output would be, and if I got X right changing Y would implicitly change X so I was struggling to find the sweet spot.

For an orthographic camera, no, it doesn’t make any sense. :stuck_out_tongue:

Yeah, if it`s orthographic and the camera never rotates, then the correct rotation will be the same for all of them.

Also, assuming this is related to your other thread about the porthole, I don`t see why you need multiple cylinders instead of just one cylinder that follows the player.

It is related, but I need every entity of a certain type to be visible through walls, so I was going to give each entity a cylinder so they will be seen through the walls. If it is always the same angle I will manually find the sweet spot and use that then.