I say rotate around Z, Unity rotates around Y

I tell unity to spin around the Z axis but in the engine it stil rotate around the y Axis. rotating around the Y and X axis isn’t a problem.

Note: Localrotation and rotation doesn’t make a diffrent.

here is the part code that does the spinning.

yRotation += Input.GetAxis(“Mouse X”) * lookSensitivity;
currentYRotation = Mathf.SmoothDamp(currentYRotation, yRotation, yRotationV, lookSmoothDamp);
var Rotate: Vector3;

		if(place== "y"){
		
			Rotate= Vector3(0,currentYRotation,0);
		
		}
		if(place== "-y"){
		
			Rotate= Vector3(0,-currentYRotation,180);
		}
		
		if(place== "x"){
			
			Rotate= Vector3(currentYRotation,0,270);
			
		}
		
		if(place== "-x"){
		
			Rotate= Vector3(-currentYRotation,0,90);
			
		}
		
		if(place== "z"){
		
			Rotate= Vector3(90,0,currentYRotation);
		}
		
		if(place== "-z"){
		
			Rotate= Vector3(270,0,-currentYRotation);
		}
		
		
	
	
	transform.rotation= Quaternion.Euler(Rotate);

PS: srry for bad English if there’s any

It going to rotate around its local rotation. If it has already been rotated it will change all the axes.

It is an easy fix.

Replace

transform.rotation= Quaternion.Euler(Rotate);

with the function call:

transform.Rotate(eulerAngles : Vector3, relativeTo : Space = Space.Self)

In the first parameter you want your vector, and in the second

you want it relative to Space.World instead of Space.Self.

Quaternion.Euler() rotates like a tank barrel: global Y, then local X (elevation) then local Z (spin the barrel to look cool.) That 270 on X rotates so old forwards is up. Then the currentYrotation spins local Z, which is now Y.

I can’t think of a way to do it using just Vectior->Quat like you have, but if you have the ifs all compute quaternions, this works: Quaternion face = Quaternion.Euler(0,0,currentYrot) * Quaternion.Euler(270,0,0);. Same math, but forces the Z rotation to go first, so be on global Z. Ends with: transform.rotation = face;