I know this has been asked and answered a million times , mostly relating to y rotation for turrets etc.
but…
I am trying to make a Cube (1) Rotate around its X Axis only.
To look at another Cube object (creating a Flap ).
Local Z is facing forward correctly ,Y is Up.
Using below simple code, Cube (1) snaps to look at World Z
targetPostition = new Vector3 ( transform.position.x, target.position.y, target.position.z );
transform.LookAt(targetPostition);
If I set it to :
... new Vector3 ( target.position.x, **transform.position.y**, target.position.z );
Cube(1) stays facing forward in local position and rotates perfectly around Y only, but I need to rotate around X.
I have been through tons of answers here and elsewhere ,
have also tried using Quaternion.LookRotation , but again with .x restricted to transform.position . Cube(1) looks towards World Z only.
Im well and truly stuck here, any suggestions greatly appreciated
NOTE: * targetPosition * apologies for my mis spelling !
Thank you very much for replying
This only seems to work if the target cube is moved into a position so that Cube(1) is again looking in World Z direction.
Fantastic.
That works perfectly.
I hate to just paste stuff in without knowing how it works , but now i can get over this hurdle and onto the next one.
Thank you ever so much for your help